@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.result_menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()) {
case R.id.result_done: {
// Intent intent = new Intent(Activity.this,SettingActivity.class);
// startActivity(intent);
// return true;

}
case R.id.result_discard:{
break;
}
}
return false;
}

  

当然,还需要在Menu里添加相应XML文件:

<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android
="http://schemas.android.com/apk/res/android">
<item android:id="@+id/result_done" android:title="Done" android:showAsAction="always|withText"></item>
<item android:id="@+id/result_discard" android:title="Cancel" android:showAsAction="always|withText"></item>
</menu>

  

posted on 2011-07-15 11:43  榆钱沽酒  阅读(2180)  评论(0编辑  收藏  举报