OnItemLongClickListener is not working in a custom listview

…衆ロ難τιáo~ 提交于 2019-11-30 18:41:56

It happens due to focusability of radiobutton in listitem layout.

Add below line to root layout of your ListView's Item layout.

android:descendantFocusability="blocksDescendants"

You should use the onItemLongClickListener of the listview as follows:

lv.setOnItemLongClickListener(new OnItemLongClickListener() {

        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int pos, long id) {
            // TODO Auto-generated method stub

            Log.v("long clicked","pos"+" "+pos);

            return true;
        }
    }); 

Note that the listener isnt a derivative from the AdapterView class!!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!