How do I know when a list item in a list is focused (highlighted) in Android?

advertisements

I searched a lot but I couldn't find a straight way for that. All I need is when I clicked on a menu-item I can realize that which on of items in the list is focused? For example in the blow picture how can I know which item is highlighted(when i clicked on a button for example on the Back Button)?


You must implement an OnItemClickListener

myList.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
       YourClass yourObject = (YourClass) arg0.getItemAtPosition(arg2);
    }
}