Back to project page introToDroid4ed.
The source code is released under:
GNU General Public License
If you think the Android project introToDroid4ed listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.introtoandroid.samelayout; /*from w w w . j a v a 2s.c o m*/ import android.app.Activity; import android.content.Intent; import android.view.Menu; import android.view.MenuItem; public abstract class MenuActivity extends Activity { @Override public boolean onCreateOptionsMenu(Menu menu) { // TODO Auto-generated method stub getMenuInflater().inflate(R.menu.layout_menu, menu); menu.findItem(R.id.program_menu_item).setIntent(new Intent(this, ProgrammaticLayoutActivity.class)); menu.findItem(R.id.resource_menu_item).setIntent(new Intent(this, ResourceLayoutActivity.class)); super.onCreateOptionsMenu(menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // TODO Auto-generated method stub startActivity(item.getIntent()); super.onOptionsItemSelected(item); return true; } }