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
I think you can do something like this ((TextView)e.View).getText().toString()
You can have a Button that catch the Ítem Clicked...
You can have the element Position like this.
int position= FindViewById(Resource.Id.listIncindentes).CheckedItemPosition;
And the element value like this.
var value= FindViewById(Resource.Id.listIncindentes).GetItemAtPosition(position);
Maybe with something like this?
lvItem = lv.GetItemAtPosition(e.Position);
Although im not sure it will work with java objects, maybe try to cast this object with the help of this thread? https://forums.xamarin.com/discussion/7894/how-to-convert-a-type-to-java-lang-object
Converting Java.Lang.Object to C#:
public static class ObjectTypeHelper
{
public static T Cast<T>(this Java.Lang.Object obj) where T : class
{
var propertyInfo = obj.GetType().GetProperty("Instance");
return propertyInfo == null ? null : propertyInfo.GetValue(obj, null) as T;
}
}
List<Dictionary<string,string>> 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<string,string> selectedItem=lstItems.get(e.Position);
// toast necessary information using selectedItem object
}
try this it might help
void OnListItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
var listView = sender as ListView;
var t = tableItems[e.Position];
Android.Widget.Toast.MakeText(this, t.Heading,
Android.Widget.ToastLength.Short).Show();
}
Check the below code for use the Particular Textview and other view from Listview Items.
Like :
TextView mTextView = (TextView) listview.getChildAt(0).findViewById(R.id.text);
You can easily get the list item of Listview.