Pergunta

I would like to change the Icon of a menu item after its clicked. (I am talking about the action menu which deploys on the Action key press)

This is what I have so far:

@Override
public void onMenuItemSelected(final int menuItem) {        
    if (menuItem == MENU_ITEM_START) {  
        if(!Started){
            Started=true;
            **Intent intent = new Intent(Control.Intents.CONTROL_MENU_SHOW);
            intent.putExtra(Control.Intents.EXTRA_MENU_ITEM_ID,MENU_ITEM_START);
            intent.putExtra(Control.Intents.EXTRA_MENU_ITEM_ICON, ExtensionUtils.getUriString(mContext, R.drawable.menu_item_stop));
            sendToHostApp(intent);**            

            mHandler.postDelayed(RunnableObject, 1000);
        }
        else{
            Started=false;              
            mHandler.removeCallbacks(RunnableObject);
        }
    }

}

So, I added the bolded code (between ** and **), to start an intent to "change" the icon in the same way I create the menu the first time, however, that wont work.

Maybe wrong intent: CONTROL_MENU_SHOW?? That is the one I found in the Control Class when initializing the menu.

Any help is appreciated, thanks!!

Foi útil?

Solução

Nope, there's no way to do it directly. The way you are doing it is the only way.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top