Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Hi every one, that's my own solution : i created the showPopup method, and then i called it in the onOptionsItemSelected like this :</p> </blockquote> <pre><code>public void showPopup(){ View menuItemView = findViewById(R.id.menu_save); PopupMenu popup = new PopupMenu(getActivity(), menuItemView); MenuInflater inflate = popup.getMenuInflater(); inflate.inflate(R.menu.popup, popup.getMenu()); popup.show(); } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_save: showPopup(); return true; default: return super.onOptionsItemSelected(item); } } </code></pre> <blockquote> <p>popup.xml</p> </blockquote> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@+id/decon" android:showAsAction="ifRoom" android:title="@string/decon"/&gt; &lt;item android:id="@+id/mRes" android:showAsAction="ifRoom" android:title="@string/mesRes"/&gt; &lt;/menu&gt; </code></pre> <blockquote> <p>main.xml => it's called onCreateOptionsMenu</p> </blockquote> <pre><code>&lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt; &lt;item android:id="@+id/menu_save" android:enabled="true" android:icon="@drawable/action_save" android:showAsAction="ifRoom|withText" android:title="@string/action_save" android:visible="true"/&gt; &lt;/menu&gt; </code></pre> <p>Finally i </p> <pre><code>implements PopupMenu.OnMenuItemClickListener to @Override onMenuItemClick method. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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