tags:

views:

94

answers:

1

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
If you don't want a click handler, you can use: lv.getSelectedItem()
Leo
@Leo: Your answer is for a click, not a selection. Use `setOnItemSelectedListener()` for selection. Your point about `getSelectedItem()` is good, though.
CommonsWare