Android Listview item selection in Xamarin using VS 2012 C# -
i'm using vs 2012 working on android app. actually, want achieve this:
// lv = listview name. lv.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> myadapter, view myview, int myitemint, long mylng) { string selectedfromlist =(string) (lv.getitematposition(myitemint)); } });
but, i'm not getting setonitemclicklistener() event. reason is, i'm working in c# using xamarin. want select value or item of listview. how can this?
have activity implement listview.ionitemclicklistener this:
public class someactivity: activity, listview.ionitemclicklistener
get refence listview this:
lsitview lv = findviewbyid<listview>(resource.id.id_in_axml);
then set onitemclicklistner activity since going implement interface listview.ionitemclicklistener
lstitems.onitemclicklistener = this;
finally add activity class:
public void onitemclick(adapterview parent, view view, int position, long id) { //whatever need goes here. }
Comments
Post a Comment