Labeeb Panampullan
Labeeb Panampullan

Reputation: 34823

Android menu not displaying

My select_screen_menu.xml

<?xml version="1.0" encoding="utf-8"?>

<menu

  xmlns:android="http://schemas.android.com/apk/res/android">

  <item android:id="@+id/home_menu"
      android:icon="@drawable/home_tab"
      android:title="Home" />
 <item android:id="@+id/submit_report"
      android:icon="@drawable/submit_tab"
      android:title="Submit a Report" />
  <item android:id="@+id/search_list"
      android:icon="@drawable/search_icon"
      android:title="Search the List" />

</menu>

and my activity class used it as

public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.select_screen_menu, menu);       
  return true;
}

public boolean onOptionsItemSelected(MenuItem item) {  
  switch (item.getItemId()) {
    case R.id.home_menu: {
      Static.backwardTo(User.viewflipper,ConstandsUsed.USER_SELECT_SCREEN);
      return true;
    }
    case R.id.submit_report:
      Static.backwardTo(User.viewflipper, User.sumitAReport_PAGE);
      return true;
    case R.id.search_list:
      Static.backwardTo(User.viewflipper, User.searchTheList_PAGE);
      return true;
    default:
      return super.onOptionsItemSelected(item);      
  }
}

i have used the following code to identify the back button

public boolean onKeyDown(int keyCode, KeyEvent event) {
---
---
}

this two are not working together. The menu will work only when this onkeydown function is removed. Is there any way to use this together Do I need to do any other things?

Please help me, thanks

Upvotes: 1

Views: 3478

Answers (2)

Labeeb Panampullan
Labeeb Panampullan

Reputation: 34823

Thanks and sorry to every one. i understood my mistake actually i am always return true from the onkeydown function. when i change to return false if it is not the keycode that i need its work well

 public boolean onKeyDown(int keyCode, KeyEvent event) {
if(){
------
return true;
}
else
return false;
}

Thank you

Upvotes: 4

user479211
user479211

Reputation: 1554

If I understand you correctly, you need write it in Activity:

@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
}

Upvotes: 1

Related Questions