Android action bar menu item with actionLayout not working properly

后端 未结 4 995
野趣味
野趣味 2021-02-05 03:19

Hi I am developing an Android application. In my application I am using Sherlock action. I\'ve defined few menu items in action-bar like in following manner

<         


        
4条回答
  •  抹茶落季
    2021-02-05 04:14

    Try this code in your activity.
    Be sure to properly set your

    R.menu.menuidentifier

    R.id.menuitemidentifier

    @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.actionbarhelpmenu, menu);
            final Menu m = menu;
            final MenuItem item = menu.findItem(R.id.ActionConnection);
            item.getActionView().setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {   
                    m.performIdentifierAction(item.getItemId(), 0);
                }
            });
            return true;
        }
    

提交回复
热议问题