List of usage examples for android.view MenuItem getItemId
public int getItemId();
From source file:com.example.android.actionbarcompat.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Toast.makeText(this, "Tapped home", Toast.LENGTH_SHORT).show(); break;/* w w w . j a v a 2 s.c o m*/ case R.id.menu_refresh: Toast.makeText(this, "Fake refreshing...", Toast.LENGTH_SHORT).show(); getActionBarHelper().setRefreshActionItemState(true); getWindow().getDecorView().postDelayed(new Runnable() { @Override public void run() { getActionBarHelper().setRefreshActionItemState(false); } }, 1000); break; case R.id.menu_search: Toast.makeText(this, "Tapped search", Toast.LENGTH_SHORT).show(); break; case R.id.menu_share: Toast.makeText(this, "Tapped share", Toast.LENGTH_SHORT).show(); break; } return super.onOptionsItemSelected(item); }
From source file:li.barter.activities.HomeActivity.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { if (isMultipane() && item.getItemId() == android.R.id.home) { /* If it's a multipane layout, the drawer is already loaded * and the drawer toggle is disabled. */ return true; } else {// w w w. ja v a2 s .c o m return super.onOptionsItemSelected(item); } }
From source file:edu.csh.coursebrowser.SectionInfoActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: ///*from ww w .j a v a 2 s . c o m*/ // http://developer.android.com/design/patterns/navigation // .html#up-vs-back // NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); }
From source file:com.miz.mizuu.Actor.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: onBackPressed();/*from www. j av a2 s . co m*/ return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.haarman.listviewanimations.MainActivity.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.menu_main_github: Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(URL_GITHUB_IO)); startActivity(intent);/*from w w w.j a v a 2 s.co m*/ return true; case R.id.menu_main_beer: buy("beer"); return true; case R.id.menu_main_beer2: buy("beer2"); return true; case R.id.menu_main_beer3: buy("beer3"); return true; case R.id.menu_main_beer4: buy("beer4"); return true; } return super.onOptionsItemSelected(item); }
From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0:/*from w w w. ja v a 2s . co m*/ if (webview.canGoBack()) webview.goBack(); break; case 1: if (webview.canGoForward()) webview.goForward(); break; case 2: webview.reload(); break; case 3: this.finish(); break; case 4: selectURL(); break; } return false; }
From source file:dentex.youtube.downloader.docs.TranslatorsListActivity.java
@Override public boolean onOptionsItemSelected(android.view.MenuItem item) { if (item.getItemId() == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return true; }/*w w w .j a v a 2s .c o m*/ return super.onOptionsItemSelected(item); }
From source file:net.idlesoft.android.apps.github.activities.BranchesList.java
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case 0:/* w w w . ja v a 2 s .c o m*/ final Intent i1 = new Intent(this, Hubroid.class); startActivity(i1); return true; case 1: mEditor.clear().commit(); final Intent intent = new Intent(this, Hubroid.class); startActivity(intent); return true; case 2: final File root = Environment.getExternalStorageDirectory(); if (root.canWrite()) { final File hubroid = new File(root, "hubroid"); if (!hubroid.exists() && !hubroid.isDirectory()) { return true; } else { hubroid.delete(); return true; } } } return false; }
From source file:edu.nimbus.glass.TopicMenuActivity.java
/** * This method here will either kill the live card, show or switch the view by starting the * feild select service.//from w ww.j av a 2 s .c om */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.stop: stopService(new Intent(this, TopicService.class)); return true; case R.id.graph_view: //create a list of fields from the current topic and have the user select which field to view. Log.d("Menu:", "Switching to graph view"); ArrayList<String> messageFields = createFieldList(mCompassService.getOriginalMessage()); Intent startIntent = new Intent(this, TopicFieldSelectActivity.class); startIntent.putStringArrayListExtra("field_names", messageFields); startIntent.putExtra("topic", mCompassService.getCurrentTopic()); startActivity(startIntent); return true; case R.id.text_view: //create a list of fields from the current topic and have the user select which field to view. Log.d("Menu:", "Switching to text view"); ArrayList<String> mFields = createFieldList(mCompassService.getOriginalMessage()); Intent sint = new Intent(this, TopicFieldSelectActivity.class); sint.putStringArrayListExtra("field_names", mFields); sint.putExtra("textual", true); sint.putExtra("topic", mCompassService.getCurrentTopic()); startActivity(sint); return true; default: return super.onOptionsItemSelected(item); /* * In the event of the user selecting "graph" or "text" and then * a specific field for an in depth view of that field, an intent will * be sent to the service, which in turn will forward the information * to the renderer. * * Messages will likely be of the form (0, field) for graphing and (1, field) for * in depth text and (2, null) for return to all topics view */ } }
From source file:com.mifos.mifosxdroid.LoginActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.offline) startActivity(new Intent(this, OfflineCenterInputActivity.class)); return super.onOptionsItemSelected(item); }