Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid -- Problems with Checkable menu items
    text
    copied!<p>I have read the instructions at the android developers page's in order to get the Checkable menu items:</p> <p><a href="http://developer.android.com/guide/topics/ui/menus.html" rel="noreferrer">http://developer.android.com/guide/topics/ui/menus.html</a></p> <p>this is my xmlmenu:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;group android:checkableBehavior="all"&gt; &lt;item android:id="@+id/regu" android:title="@string/Regulatory" /&gt; &lt;item android:id="@+id/warn" android:title="@string/Warning" /&gt; &lt;item android:id="@+id/temp" android:title="@string/Temporary" /&gt; &lt;item android:id="@+id/bicy" android:title="@string/Bicycle" /&gt; &lt;/group&gt; &lt;/menu&gt; </code></pre> <p>And here is my code:</p> <pre><code> @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.regu: if (item.isChecked()) { item.setChecked(false); currAvailableOptions++; } else if(0 != currAvailableOptions) { item.setChecked(true); currAvailableOptions--; } return true; case R.id.warn: if (item.isChecked()) { item.setChecked(false); currAvailableOptions++; } else if(0 != currAvailableOptions) { item.setChecked(true); currAvailableOptions--; } return true; case R.id.temp: if (item.isChecked()) { item.setChecked(false); currAvailableOptions++; } else if(0 != currAvailableOptions) { item.setChecked(true); currAvailableOptions--; } return true; default: return super.onOptionsItemSelected(item); } } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.app_menu, menu); return true; } </code></pre> <p>The problem is when I clicked one item, the menu item disappeared. It wouldn't have to stay visible in order to check other menu items?</p> <p>Any idea?</p> <p>Greetings </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload