Android Question Appcompat Menu vs Menu Key

Discussion in 'Android Questions' started by tchart, Jun 2, 2015.

  1. tchart

    tchart Active Member Licensed User

    I'm using Appcompat (ie #Extends: android.support.v7.app.AppCompatActivity).

    I've noticed that the menu appears in the bar at the top which the user can click to show/hide.

    However I also notice that if I press the physical menu key (on my Note 3) I get a menu at the bottom.

    Is there any way to disable the bottom menu or even have the physical menu key show/hide the appcompat menu at the top?

    Examples below.

    2015-06-02 08.33.01.png 2015-06-02 08.32.53.png
     
  2. thedesolatesoul

    thedesolatesoul Expert Licensed User

    You can override it in Activity_Keypress
     
    DonManfred likes this.
  3. tchart

    tchart Active Member Licensed User

    Thanks TDS, Ive got that part but I would like to show/hide the top right menu when the user presses the menu physical key. I guess I can just interecept the menu pkey and force the user to push the toolbar menu but it would be nicer to show the menu.

    Something like this Java code but I dont know how to get the toolbar menu object;

    Code:
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        
    if (keyCode == KeyEvent.KEYCODE_MENU) {
            
    if (mToolbar.isOverflowMenuShowing()) {
                mToolbar.hideOverflowMenu();
            
    } else {
                mToolbar.showOverflowMenu();
            }
            return true;
        }
        return super.onKeyUp(keyCode, event);
    }
     
  4. thedesolatesoul

    thedesolatesoul Expert Licensed User

    Yes, that is what I would have expected.
    Can you do ACToolbar.getMenu ...although that doesnt do anything

    As much as I hate reflection...
    Code:
    Sub ShowOverflowMenu(myToolbar as ACToolbar)
      
    Dim jo as JavaObject
      jo = myToolbar
      jo.RunMethod(
    "showOverflowMenu")
    End Sub
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice