Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Firstly, I wouldn't recommend defining your own style of menu. In my personal opinion this isn't something that should be changed. It will also be useless for ICS+ devices as they will not have a dedicated menu button.</p> <p>However, if you wish to do it, you are going to have to step away from the existing menu set up as it is not possible to change the default behavior. </p> <p>What you are going to need to do is create a hidden layout inside the existing layout for your activity, then hook onto the getKeyDown event to hide/show this layout.</p> <pre><code>@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { myCustomMenu.toggleVisibility(); return true; } else { return super.onKeyDown(keyCode, event); } } </code></pre> <p>The method could look something like this</p> <pre><code>public void toggleVisibility() { LinearLayout myCustomMenuLayout = (LinearLayout) findViewById(R.id.myCustomMenu); if (myCustomMenuLayout.getVisibility() == View.GONE) { myCustomMenuLayout.setVisibility(View.VISIBLE); } else { myCustomMenuLayout.setVisibility(View.GONE); } } </code></pre> <p>When it comes to the layout, it is probably for the best if you create it in a separate layout then just reference it like I have below. This is so you can reference it multiple times without the code duplication.</p> <pre><code>&lt;include android:id="@+id/myCustomMenu" layout="@layout/customMenu" visibility="gone"&gt; </code></pre> <p>From there you just need to populate the menu and define the onclicklisteners etc</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    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