on long click listener ListActivity class

前端 未结 1 1639
北海茫月
北海茫月 2020-12-19 18:24

I have an app which use ListView,I have set onListItemClick event to view details about contact,and I want to implement onLongListItemClick to show a dialog and I don\'t kno

相关标签:
1条回答
  • 2020-12-19 18:47

    Try like this :

    listview.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                    int arg2, long arg3) {
                Toast.makeText(getApplicationContext(), "Long Clicked : ", Toast.LENGTH_LONG).show();
                return true;
            }
    });
    

    You need to add return true; here otherwise it will transfer control to single click event listener once you release your touch.

    Hope it helps you.

    Thanks.

    0 讨论(0)
提交回复
热议问题