List of usage examples for android.view Menu clear
public void clear();
From source file:nz.ac.auckland.lablet.ExperimentRunViewManager.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.perform_experiment_activity_actions, menu); // back item/*from www . j a va 2 s . c o m*/ MenuItem backItem = menu.findItem(R.id.action_done); assert backItem != null; backItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { onBackPressed(); return false; } }); // analyse item MenuItem analyseItem = menu.findItem(R.id.action_analyse); assert analyseItem != null; analyseMenuItem.setMenuItem(analyseItem); if (!experiment.getCurrentExperimentRun().dataTaken()) analyseMenuItem.setEnabled(false); analyseItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { finishExperiment(true); return true; } }); // settings item MenuItem settingsMenu = menu.findItem(R.id.action_settings); assert settingsMenu != null; settingsMenuItem.setMenuItem(settingsMenu); // sensor view item MenuItem viewMenu = menu.findItem(R.id.action_view); assert viewMenu != null; viewMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { showViewMenu(); return true; } }); // activate sensorDataList item MenuItem sensorMenu = menu.findItem(R.id.action_sensors); assert sensorMenu != null; sensorMenuItem.setMenuItem(sensorMenu); sensorMenu.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { showSensorMenu(); return true; } }); // config the menu Bundle options = ExperimentHelper.unpackStartExperimentOptions(getIntent()); if (options != null) { boolean showAnalyseMenu = options.getBoolean("show_analyse_menu", true); analyseMenuItem.setVisible(showAnalyseMenu); boolean sensorsEditable = options.getBoolean("sensors_editable", true); sensorMenu.setVisible(sensorsEditable); if (!sensorsEditable) { if (experiment.getCurrentExperimentRun().getExperimentSensors().size() == 1) viewMenu.setVisible(false); } } return true; }
From source file:com.bangz.smartmute.LocationsMapFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { Activity parentActivity = getActivity(); if (!(parentActivity instanceof BaseActivity && ((BaseActivity) parentActivity).isDrawerOpened())) { menu.clear(); inflater.inflate(R.menu.menu_locations_map, menu); super.onCreateOptionsMenu(menu, inflater); }//from w w w.ja v a2 s. co m }
From source file:org.rebo.app.TileMap.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { if (!isPreHoneyComb()) { menu.clear(); onCreateOptionsMenu(menu);/*from www.j av a2 s. co m*/ } menu.findItem(R.id.menu_position_map_center).setVisible(false); return super.onPrepareOptionsMenu(menu); }
From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.details, menu); MenuItem navToStation = menu.findItem(R.id.nav_to_station); navToStation.getIcon().mutate();//from ww w . ja va2 s.com navToStation.getIcon().setColorFilter(WHITE, PorterDuff.Mode.SRC_ATOP); if (localFotoUsed) { enableMenuItem(menu, R.id.photo_upload); } else { disableMenuItem(menu, R.id.photo_upload); } if (localFotoUsed || bahnhof.hasPhoto()) { enableMenuItem(menu, R.id.share_photo); } else { disableMenuItem(menu, R.id.share_photo); } return super.onPrepareOptionsMenu(menu); }
From source file:nl.thehyve.transmartclient.MainActivity.java
private void refreshNavigationMenu() { NavigationView mNavigationView = (NavigationView) findViewById(R.id.nav_view); final Menu menu = mNavigationView.getMenu(); List<TransmartServer> connectedServers = getConnectedServers(); menu.clear(); int order = 0; int group = 1; SubMenu serverMenu = menu.addSubMenu(Menu.NONE, order, order, getString(R.string.menu_serversSubmenu)); order += 1;/* w w w. ja v a 2 s . c o m*/ for (TransmartServer transmartServer : connectedServers) { int menuItemID = serverMenu.add(group, order, order, transmartServer.getServerLabel()) .setIcon(R.drawable.ic_action_accounts).getItemId(); transmartServer.setMenuItemID(menuItemID); order += 1; } add_server_item = serverMenu.add(group, order, order, R.string.menu_addNewServer) .setIcon(R.drawable.ic_action_new_account).getItemId(); order += 1; serverMenu.setGroupCheckable(group, true, true); about_item = menu.add(Menu.NONE, order, order, R.string.menu_about).setIcon(R.drawable.ic_action_about) .getItemId(); }
From source file:com.yeldi.yeldibazaar.AppDetails.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.clear(); if (app == null) return true; DB.Apk curver = app.getCurrentVersion(); if (app.hasUpdates == true) { MenuItemCompat.setShowAsAction(/*from w ww . j a va 2 s . c o m*/ menu.add(Menu.NONE, INSTALL, 0, R.string.menu_update).setIcon(R.drawable.ic_menu_refresh), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } if (app.installedVersion == null && curver != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, INSTALL, 1, R.string.menu_install).setIcon(android.R.drawable.ic_menu_add), MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } else if (app.installedVersion != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall) .setIcon(android.R.drawable.ic_menu_delete), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); if (mPm.getLaunchIntentForPackage(app.id) != null) { MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch) .setIcon(android.R.drawable.ic_media_play), MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); } } MenuItemCompat.setShowAsAction( menu.add(Menu.NONE, SHARE, 1, R.string.menu_share).setIcon(android.R.drawable.ic_menu_share), MenuItemCompat.SHOW_AS_ACTION_IF_ROOM | MenuItemCompat.SHOW_AS_ACTION_WITH_TEXT); if (app.detail_webURL.length() > 0) { menu.add(Menu.NONE, WEBSITE, 2, R.string.menu_website).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_trackerURL.length() > 0) { menu.add(Menu.NONE, ISSUES, 3, R.string.menu_issues).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_sourceURL.length() > 0) { menu.add(Menu.NONE, SOURCE, 4, R.string.menu_source).setIcon(android.R.drawable.ic_menu_view); } menu.add(Menu.NONE, MARKET, 5, R.string.menu_market).setIcon(android.R.drawable.ic_menu_view); if (app.detail_bitcoinAddr != null) { menu.add(Menu.NONE, BITCOIN, 6, R.string.menu_bitcoin).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_flattrID != null) { menu.add(Menu.NONE, FLATTR, 7, R.string.menu_flattr).setIcon(android.R.drawable.ic_menu_view); } if (app.detail_donateURL != null) { menu.add(Menu.NONE, DONATE, 8, R.string.menu_donate).setIcon(android.R.drawable.ic_menu_view); } return true; }
From source file:com.ibuildapp.romanblack.NewsPlugin.NewsPlugin.java
/** * This menu contains reverse and refresh buttons * *///from w w w . java 2 s .c o m @Override public boolean onPrepareOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.news_menu_main, menu); menu.clear(); MenuItem menuItem = menu.add(""); menuItem.setTitle(getString(R.string.news_reverse)); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { handler.sendEmptyMessage(REVERSE_LIST); return true; } }); if (Statics.isRSS) { menuItem = menu.add(""); menuItem.setTitle(R.string.news_refresh); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (isOnline) { handler.sendEmptyMessage(REFRESH_RSS); } else { handler.sendEmptyMessage(CANT_REFRESH_RSS); } return true; } }); } return false; }
From source file:de.gebatzens.sia.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(SIAApp.SIA_APP.school.getTheme()); super.onCreate(savedInstanceState); Log.w("ggvp", "CREATE NEW MAINACTIVITY"); //Debug.startMethodTracing("sia3"); SIAApp.SIA_APP.activity = this; savedState = savedInstanceState;//from w w w . j a va 2s.com final FragmentData.FragmentList fragments = SIAApp.SIA_APP.school.fragments; Intent intent = getIntent(); if (intent != null && intent.getStringExtra("fragment") != null) { FragmentData frag = fragments .getByType(FragmentData.FragmentType.valueOf(intent.getStringExtra("fragment"))).get(0); SIAApp.SIA_APP.setFragmentIndex(fragments.indexOf(frag)); } if (intent != null && intent.getBooleanExtra("reload", false)) { SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); intent.removeExtra("reload"); } setContentView(R.layout.activity_main); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); mContent = getFragment(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); Log.d("ggvp", "DATA: " + fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData()); if (fragments.get(SIAApp.SIA_APP.getFragmentIndex()).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); if ("Summer".equals(SIAApp.SIA_APP.getCurrentThemeName())) { ImageView summerNavigationPalm = (ImageView) findViewById(R.id.summer_navigation_palm); summerNavigationPalm.setImageResource(R.drawable.summer_palm); ImageView summerBackgroundImage = (ImageView) findViewById(R.id.summer_background_image); summerBackgroundImage.setImageResource(R.drawable.summer_background); } mToolBar = (Toolbar) findViewById(R.id.toolbar); mToolBar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.action_refresh: ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)).setRefreshing(true); SIAApp.SIA_APP.refreshAsync(new Runnable() { @Override public void run() { ((SwipeRefreshLayout) mContent.getView().findViewById(R.id.refresh)) .setRefreshing(false); } }, true, fragments.get(SIAApp.SIA_APP.getFragmentIndex())); return true; case R.id.action_settings: Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); return true; case R.id.action_addToCalendar: showExamDialog(); return true; case R.id.action_help: AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setTitle(getApplication().getString(R.string.help)); builder.setMessage(getApplication().getString(R.string.exam_explain)); builder.setPositiveButton(getApplication().getString(R.string.close), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.create().show(); return true; } return false; } }); updateToolbar(SIAApp.SIA_APP.school.name, fragments.get(SIAApp.SIA_APP.getFragmentIndex()).name); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { SIAApp.SIA_APP.setStatusBarColorTransparent(getWindow()); // because of the navigation drawer } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolBar, R.string.drawer_open, R.string.drawer_close) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { super.onDrawerClosed(view); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { super.onDrawerOpened(drawerView); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.addDrawerListener(mDrawerToggle); navigationView = (NavigationView) findViewById(R.id.navigation_view); mNavigationHeader = navigationView.getHeaderView(0); mNavigationSchoolpictureText = (TextView) mNavigationHeader.findViewById(R.id.drawer_image_text); mNavigationSchoolpictureText.setText(SIAApp.SIA_APP.school.name); mNavigationSchoolpicture = (ImageView) mNavigationHeader.findViewById(R.id.navigation_schoolpicture); mNavigationSchoolpicture.setImageBitmap(SIAApp.SIA_APP.school.loadImage()); mNavigationSchoolpictureLink = mNavigationHeader.findViewById(R.id.navigation_schoolpicture_link); mNavigationSchoolpictureLink.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View viewIn) { mDrawerLayout.closeDrawers(); Intent linkIntent = new Intent(Intent.ACTION_VIEW); linkIntent.setData(Uri.parse(SIAApp.SIA_APP.school.website)); startActivity(linkIntent); } }); final Menu menu = navigationView.getMenu(); menu.clear(); for (int i = 0; i < fragments.size(); i++) { MenuItem item = menu.add(R.id.fragments, Menu.NONE, i, fragments.get(i).name); item.setIcon(fragments.get(i).getIconRes()); } menu.add(R.id.settings, R.id.settings_item, fragments.size(), R.string.settings); menu.setGroupCheckable(R.id.fragments, true, true); menu.setGroupCheckable(R.id.settings, false, false); final Menu navMenu = navigationView.getMenu(); selectedItem = SIAApp.SIA_APP.getFragmentIndex(); if (selectedItem != -1) navMenu.getItem(selectedItem).setChecked(true); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.settings_item) { mDrawerLayout.closeDrawers(); Intent i = new Intent(MainActivity.this, SettingsActivity.class); startActivityForResult(i, 1); } else { final int index = menuItem.getOrder(); if (SIAApp.SIA_APP.getFragmentIndex() != index) { SIAApp.SIA_APP.setFragmentIndex(index); menuItem.setChecked(true); updateToolbar(SIAApp.SIA_APP.school.name, menuItem.getTitle().toString()); mContent = getFragment(); Animation fadeOut = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fadeOut.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.setVisibility(View.INVISIBLE); if (fragments.get(index).getData() == null) SIAApp.SIA_APP.refreshAsync(null, true, fragments.get(index)); //removeAllFragments(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.content_fragment, mContent, "gg_content_fragment"); transaction.commit(); snowView.updateSnow(); } @Override public void onAnimationRepeat(Animation animation) { } }); FrameLayout contentFrame = (FrameLayout) findViewById(R.id.content_fragment); contentFrame.startAnimation(fadeOut); mDrawerLayout.closeDrawers(); } else { mDrawerLayout.closeDrawers(); } } return true; } }); if (Build.VERSION.SDK_INT >= 25) { ShortcutManager shortcutManager = getSystemService(ShortcutManager.class); shortcutManager.removeAllDynamicShortcuts(); for (int i = 0; i < fragments.size(); i++) { Drawable drawable = getDrawable(fragments.get(i).getIconRes()); Bitmap icon; if (drawable instanceof VectorDrawable) { icon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(icon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } else { icon = BitmapFactory.decodeResource(getResources(), fragments.get(i).getIconRes()); } Bitmap connectedIcon = Bitmap.createBitmap(icon.getWidth(), icon.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(connectedIcon); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#f5f5f5")); canvas.drawCircle(icon.getWidth() / 2, icon.getHeight() / 2, icon.getWidth() / 2, paint); paint.setColorFilter( new PorterDuffColorFilter(SIAApp.SIA_APP.school.getColor(), PorterDuff.Mode.SRC_ATOP)); canvas.drawBitmap(icon, null, new RectF(icon.getHeight() / 4.0f, icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f, icon.getHeight() - icon.getHeight() / 4.0f), paint); Intent newTaskIntent = new Intent(this, MainActivity.class); newTaskIntent.setAction(Intent.ACTION_MAIN); newTaskIntent.putExtra("fragment", fragments.get(i).type.toString()); ShortcutInfo shortcut = new ShortcutInfo.Builder(this, fragments.get(i).name) .setShortLabel(fragments.get(i).name).setLongLabel(fragments.get(i).name) .setIcon(Icon.createWithBitmap(connectedIcon)).setIntent(newTaskIntent).build(); shortcutManager.addDynamicShortcuts(Arrays.asList(shortcut)); } } if (SIAApp.SIA_APP.preferences.getBoolean("app_130_upgrade", true)) { if (!SIAApp.SIA_APP.preferences.getBoolean("first_use_filter", true)) { TextDialog.newInstance(R.string.upgrade1_3title, R.string.upgrade1_3) .show(getSupportFragmentManager(), "upgrade_dialog"); } SIAApp.SIA_APP.preferences.edit().putBoolean("app_130_upgrade", false).apply(); } snowView = (SnowView) findViewById(R.id.snow_view); shareToolbar = (Toolbar) findViewById(R.id.share_toolbar); shareToolbar.getMenu().clear(); shareToolbar.inflateMenu(R.menu.share_toolbar_menu); shareToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { toggleShareToolbar(false); for (Shareable s : MainActivity.this.shared) { s.setMarked(false); } MainActivity.this.shared.clear(); mContent.updateFragment(); } }); shareToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { toggleShareToolbar(false); HashMap<Date, ArrayList<Shareable>> dates = new HashMap<Date, ArrayList<Shareable>>(); for (Shareable s : MainActivity.this.shared) { ArrayList<Shareable> list = dates.get(s.getDate()); if (list == null) { list = new ArrayList<Shareable>(); dates.put(s.getDate(), list); } list.add(s); s.setMarked(false); } MainActivity.this.shared.clear(); List<Date> dateList = new ArrayList<Date>(dates.keySet()); Collections.sort(dateList); String content = ""; for (Date key : dateList) { content += SubstListAdapter.translateDay(key) + "\n\n"; Collections.sort(dates.get(key)); for (Shareable s : dates.get(key)) { content += s.getShareContent() + "\n"; } content += "\n"; } content = content.substring(0, content.length() - 1); mContent.updateFragment(); if (item.getItemId() == R.id.action_copy) { ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText(getString(R.string.entries), content); clipboard.setPrimaryClip(clip); } else if (item.getItemId() == R.id.action_share) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, content); sendIntent.setType("text/plain"); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to))); } return true; } }); if (shared.size() > 0) { shareToolbar.setVisibility(View.VISIBLE); updateShareToolbarText(); } // if a fragment is opened via a notification or a shortcut reset the shared entries // delete extra fragment because the same intent is used when the device gets rotated and the user could have opened a new fragment if (intent != null && intent.hasExtra("fragment")) { resetShareToolbar(); intent.removeExtra("fragment"); } }
From source file:org.runbuddy.tomahawk.activities.TomahawkMainActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.clear(); getMenuInflater().inflate(R.menu.tomahawk_main_menu, menu); // customize the searchView mSearchItem = menu.findItem(R.id.action_search); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(mSearchItem); SearchViewStyle.on(searchView).setSearchPlateDrawableId(R.drawable.edittext_background) .setCursorColor(getResources().getColor(R.color.tomahawk_red)); searchView.setQueryHint(getString(R.string.search)); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override//from w w w . ja va 2 s . co m public boolean onQueryTextSubmit(String query) { if (query != null && !TextUtils.isEmpty(query)) { DatabaseHelper.get().addEntryToSearchHistory(query); Bundle bundle = new Bundle(); bundle.putString(TomahawkFragment.QUERY_STRING, query); bundle.putInt(TomahawkFragment.CONTENT_HEADER_MODE, ContentHeaderFragment.MODE_HEADER_STATIC); FragmentUtils.replace(TomahawkMainActivity.this, SearchPagerFragment.class, bundle); if (mSearchItem != null) { MenuItemCompat.collapseActionView(mSearchItem); } searchView.clearFocus(); return true; } return false; } @Override public boolean onQueryTextChange(String newText) { Cursor cursor = DatabaseHelper.get().getSearchHistoryCursor(newText); if (cursor.getCount() != 0) { String[] columns = new String[] { TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY }; int[] columnTextId = new int[] { android.R.id.text1 }; SuggestionSimpleCursorAdapter simple = new SuggestionSimpleCursorAdapter(getBaseContext(), R.layout.searchview_dropdown_item, cursor, columns, columnTextId, 0); if (searchView.getSuggestionsAdapter() != null && searchView.getSuggestionsAdapter().getCursor() != null) { searchView.getSuggestionsAdapter().getCursor().close(); } searchView.setSuggestionsAdapter(simple); return true; } else { cursor.close(); return false; } } }); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { SQLiteCursor cursor = (SQLiteCursor) searchView.getSuggestionsAdapter().getItem(position); int indexColumnSuggestion = cursor.getColumnIndex(TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY); searchView.setQuery(cursor.getString(indexColumnSuggestion), false); return true; } @Override public boolean onSuggestionClick(int position) { SQLiteCursor cursor = (SQLiteCursor) searchView.getSuggestionsAdapter().getItem(position); int indexColumnSuggestion = cursor.getColumnIndex(TomahawkSQLiteHelper.SEARCHHISTORY_COLUMN_ENTRY); searchView.setQuery(cursor.getString(indexColumnSuggestion), false); return true; } }); return super.onCreateOptionsMenu(menu); }
From source file:com.pindroid.activity.Main.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerWrapper); if (drawerOpen) { menu.clear(); }//from ww w. j a va 2 s . c om return super.onPrepareOptionsMenu(menu); }