tags:

views:

63

answers:

2

My select_screen_menu.xml

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

<menu

  xmlns:android="http://schemas.android.com/apk/res/android"&gt;

  <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

A: 

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

@Override
public void onBackPressed() {
    // TODO Auto-generated method stub
    super.onBackPressed();
}
Thanks for considering me . It is not working with me. Is there any importance of it order. Actually when i put the sysout statement in onkeydown function, I understood it reaching control over there when i press the menu
Labeeb P
Is there any way for me to call the menu by code so that i can identify the menu press in onkeydown function and call by code thanks
Labeeb P
+1  A: 

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

Labeeb P