How to add Focuschange Listner to listview in android

Posted by jayanthgande on Stack Overflow See other posts from Stack Overflow or by jayanthgande
Published on 2010-04-28T10:17:28Z Indexed on 2010/04/28 10:23 UTC
Read the original article Hit count: 391

Filed under:
|
|

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

© Stack Overflow or respective owner

Related posts about android

Related posts about listview