コード例 #1
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   super.onCreateOptionsMenu(menu);
   final MenuItem item =
       menu.add(0, 1, Menu.NONE, myResource.getResource("menu").getResource("search").getValue());
   item.setOnMenuItemClickListener(this);
   item.setIcon(R.drawable.ic_menu_search);
   return true;
 }
コード例 #2
0
ファイル: AppsFragment.java プロジェクト: velvettear/sad
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   inflater.inflate(R.menu.main, menu);
   MenuItem deselectItem = menu.findItem(R.id.menu_main_deselect);
   MenuItem stateItem = menu.findItem(R.id.menu_main_state);
   if (((AppsAdapter) lvApps.getAdapter()).hasSelectedItem()) {
     if (fragmentMode == Statics.FRAGMENT_ENABLED) {
       stateItem.setTitle(getResources().getString(R.string.disable_app));
       stateItem.setTitleCondensed(getResources().getString(R.string.disable));
       stateItem.setIcon(getResources().getDrawable(R.drawable.ic_disable, null));
     } else {
       stateItem.setTitle(getResources().getString(R.string.enable_app));
       stateItem.setTitleCondensed(getResources().getString(R.string.enable));
       stateItem.setIcon(getResources().getDrawable(R.drawable.ic_enable, null));
     }
     deselectItem.setVisible(true);
     stateItem.setVisible(true);
   } else {
     deselectItem.setVisible(false);
     stateItem.setVisible(false);
   }
   super.onCreateOptionsMenu(menu, inflater);
 }