Search code examples
androidsimpleadapter

SimpleAdapter retrieve String


I have a SimpleAdapter with only 2 Textviews populating a list.I would like to retrieve one of these textview strings onListItemClicked(). I can get an

Object o = adapter.getItem(position); 

But I would like the String? Any ideas?


Solution

  • The second parameter of the onListItemClicked callback is a View representing that row. You could use that row to search for the desired TextView and obtain the String from that:

    TextView txt = (TextView) view.findViewById(R.id.the_desired_textview_id);
    String str = txt.getText().toString();