How can I create an android menu item using android setting icon

后端 未结 4 2030
天涯浪人
天涯浪人 2020-12-23 20:12

Can you please tell me how can I create an android menu item using android setting icon?

4条回答
  •  太阳男子
    2020-12-23 20:36

    If you want to handle the event, just try this on your activity

    @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            switch (item.getItemId()) {
                // action with ID action_refresh was selected
                case android.R.drawable.ic_popup_sync:
                    Toast.makeText(this, "ic_popup_sync selected", Toast.LENGTH_SHORT)
                            .show();
                    break;
                default:
                    break;
            }
    
            return true;
        }
    

    And in your menu folder use something like this:

    
    
        
    
        
    
        
    
    
    
    

提交回复
热议问题