I need to get the selected Item from a ListView in adnroid .
A:
You would use similar code to the following:
ListView lv = (ListView)this.findViewById(android.R.id.list);
lv.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
// Your code goes here.
}
});
Leo
2010-09-11 10:42:23
If you don't want a click handler, you can use: lv.getSelectedItem()
Leo
2010-09-11 10:44:03
@Leo: Your answer is for a click, not a selection. Use `setOnItemSelectedListener()` for selection. Your point about `getSelectedItem()` is good, though.
CommonsWare
2010-09-11 11:59:38