onOptionsItemSelected() not called when clicking on menu item which has an actionLayout set on it

后端 未结 1 784
生来不讨喜
生来不讨喜 2021-01-13 10:35

In my action bar, I have defined a menu item that can show text \"DONE\" by the code below:

Menu.xml:



        
相关标签:
1条回答
  • 2021-01-13 11:05

    Use this as shown in onOptionsItemSelected not called when using actionLayout (SherlockActionBar)

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getSupportMenuInflater().inflate(R.menu.map_menu, menu);
        for (int i = 0; i < menu.size(); i++) {
            MenuItem item = menu.getItem(i);
            if (item.getItemId() == R.id.menu_more) {
                itemChooser = item.getActionView();
                if (itemChooser != null) {
                    itemChooser.setOnClickListener(this);
                }
            }
        }
        return super.onCreateOptionsMenu(menu);
    }
    
    0 讨论(0)
提交回复
热议问题