How to add Focuschange Listner to listview in android
- by jayanthgande
Hi,
I am having a listview in one of my activity.How to set foucs change listner.I tried with following block of code I am not getting result.
product_search_list = (ListView) findViewById(R.id.productlist);
product_search_list.setOnFocusChangeListener(onproductchangelistener);
private OnFocusChangeListener onproductchangelistener = new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
int index= (int) ((ListView)v).getSelectedItemId();
Log.i("index",""+index);
}
};
Actually on focus change of list items I want to get index of focused list item and do the necessary operations.
Thanks in advance.
Regards:
Jayanth