<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_settings" android:orderInCategory="100" android:title="@string/action_settings"/> </menu> enter a label for your option in android:title="@string/action_settings ============================================================== and type this coding in your layout java page // this for create a menu in the layout public boolean onCreateOptionsMenu(Menu menu) { ============================================================= // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.page, menu); return true; } //to catch the click option from the menu to identify which option selected // import MenuItem Library also public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.action_settings: //if action_setting id is chosen it will cal newproductactivity class Intent i = new Intent(getApplicationContext(), NewProductActivity.class); startActivity(i); return true; default: return super.onOptionsItemSelected(item); } } =================================================== now we have one option in option menu import MenuItem Library also
Create Option Menu in Android Application
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment