thenosic
thenosic

Reputation: 1495

context menu android

i have a listactivity in android. A context menu open when i press an item of my listview.

The problem occurs when i close this context menu and i back to press the same item (the other items have no problems)

if i press into the text, the context menu doesn't open, but if i press in white area then the contextmenu appears.

¿what's the problem?

oncreate method:

lv = getListView();

    lv.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            TextView text = (TextView) view.findViewById(R.id.label);
            if (!text.getTag().toString().equals("-1"))
            {
                registerForContextMenu(text);
                openContextMenu(text);
            }

         }
       });

Upvotes: 1

Views: 987

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007544

If you want a context menu for your ListView, call registerForContextMenu() in onCreate() of your activity, passing in the ListView. Here is a sample project demonstrating this, including showing how to determine which particular row in the ListView the user long-tapped upon to bring up the context menu.

Upvotes: 1

Related Questions