get view id from oncontextitemselected

前端 未结 5 1011
旧巷少年郎
旧巷少年郎 2020-12-11 20:11

I\'ve several buttons registered for context menu

how do I know which button was clicked for the menu to appear?

below is the pseudocode that i\'ll be using.

5条回答
  •  旧时难觅i
    2020-12-11 20:35

    try this...

    @Override
    public boolean onContextItemSelected(MenuItem item)
     {
        if(item.getItemId()==SEND_AS_TEXT)
        {
            //code for send text
        } 
        else if(item.getItemId()==SEND_AS_IMAGE)
        {
           //code for send image
        }
        return super.onContextItemSelected(item);
    }
    

提交回复
热议问题