android: changing option menu items programmatically

前端 未结 12 1919
终归单人心
终归单人心 2020-12-02 09:33

Is it possible to change the option menu items programmatically? Can anyone provide me with an example please?

Also, I want to disable certain items, so that they do

12条回答
  •  隐瞒了意图╮
    2020-12-02 10:26

    @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            MenuInflater inflater = getMenuInflater();
            inflater.inflate(R.menu.calendar, menu);
            if(show_list == true) {         
    
            if(!locale.equalsIgnoreCase("sk")) menu.findItem(R.id.action_cyclesn).setVisible(false);
    
            return true;
        }
    

提交回复
热议问题