Hello!
Try use this code.
Hope, it helps You!

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        switch (keyCode){
                case KeyEvent.KEYCODE_MENU:{
                        return true;
                }
                default: return true;
        }
        //return super.onKeyDown(keyCode, event);
    }

On 23 июл, 02:51, mwllace <[email protected]> wrote:
> I'm new to Android and I'm a front end designer. Im trying to get the
> Android menu buttons to open a new activity using a case statement to
> specify the activity. The activity works when I set it to any other
> button in the App. The menu shows up when the hard menu button is
> pressed, but they will not link to the specified Activity. I'm stuck
> and I know I'm overlooking something simple. Can anyone help?
>
> The code:
>
> @Override
>          public boolean onCreateOptionsMenu(Menu menu) {
>
>                     menu.setQwertyMode(true);
>                     menu.add(0,MENU1, 0, 
> R.string.about).setIcon(R.drawable.icon);
> ;
>                         menu.add(0, MENU2, 0, 
> R.string.usage).setIcon(R.drawable.icon);
> ;
>                     return true;
>                     }
>
>          public boolean OnOptionsItemSelected(MenuItem item){
>                  switch (item.getItemId()) {
>                  case MENU1:
>
>                          Toast.makeText(getApplicationContext(),
>                     "About  was clicked.",
>                      Toast.LENGTH_SHORT).show();
>
>                          Intent intent = new Intent(XActivity.this, 
> AboutActivity.class);
>                          startActivity(intent);
>
>                          return true;
>                  case MENU2:
>                      finish();
>                  return true;
>
>                  }
>                  return false;
>          }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to