How to add Focuschange Listner to listview in android
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
你可能想要setOnItemSelectedListener()
,而不是setOnFocusChangeListener()
。
上一篇: 有3D文本着色器是非