Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Click event in adapter

rajveerrajveer USMember ✭✭
edited October 2015 in Xamarin.Android

I'm trying to add click event in the BaseAdapter , but unfortunately it get call to GetView() multiple times. My code in GetView() is like

List<ShowLinks> items; var download = view.FindViewById (Resource.Id.imageview1) as ImageView; download.Click += (object sender, EventArgs e) =>{ string url = "http:"+items [position].LinkUrl; WebClient WC= new WebClient(); WC.DownloadStringAsync(new Uri(url)); };

Then my click event repeats for all the items in the List, but my requirement is it should accept only selected item.


  • BerayBentesenBerayBentesen TRUniversity ✭✭✭✭

    re-define your ListView inside OnCreate and when you write YourListViewName.ItemClick += you will see click methods.

  • rajveerrajveer USMember ✭✭

    Thanks @ashalva & @BerayBentesen finally it works by using

    private void ListItemClicked(object sender, AdapterView.ItemClickEventArgs e) { //you can get the item with the position var item = myList[e]; }

Sign In or Register to comment.