creating a menu after a long click event on a list view

前端 未结 7 676
無奈伤痛
無奈伤痛 2020-12-02 07:32

I have a list view connected to a database, showing a all the entries. I want a menu to show up if the user long clicks a item in the listview(database entry), showing optio

7条回答
  •  伪装坚强ぢ
    2020-12-02 07:47

    Instead of using onItemLongClick you can use

    public void onCreateContextMenu(final ContextMenu menu, 
                        final View v, final ContextMenuInfo menuInfo) {
     ...
    }
    

    where you setup the options for edit and delete or whatever you need to.

    The actions for the item selected from the context menu can be processed in

    public boolean onContextItemSelected(final MenuItem item)
    

    For more information on context menu see here.

    For a step by step tutorial visit here.

提交回复
热议问题