How to get the data of a ListView item the user has clicked on with listview.GetItemAtPosition(e.Position)?

后端 未结 6 1818
温柔的废话
温柔的废话 2021-01-23 00:36

in a Xamarin.Android app, I have a ListView which I previously populated. In the listview_ItemClick event handler, which correctly fires, I would like to retrieve the text of t

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 01:20

    List> lstItems;
    

    lstItems contains all the list item, which is loaded in the listview. From the listView click listener you will get the position of the selected item. Suppose it is i. Then you can take that item from lstItems.

    private void lv_ItemClick(object sender, AdapterView.ItemClickEventArgs e) {
    
        Dictionary selectedItem=lstItems.get(e.Position);
        // toast necessary information using selectedItem object
    
    }
    

提交回复
热议问题