List of usage examples for android.view MenuItem getTitle
public CharSequence getTitle();
From source file:com.velli.passwordmanager.FragmentPasswordsBase.java
public void onNavigationItemSelection(MenuItem item) { int id = item.getItemId(); if (id != R.id.navigation_item_settings && id != R.id.navigation_item_log_out && id != R.id.navigation_item_manage_groups) { mLastSelectedNavItemId = id;/*w ww . j a va 2s . c om*/ final ActionBar bar = ((AppCompatActivity) getActivity()).getSupportActionBar(); if (bar != null) { bar.setTitle(item.getTitle().toString()); } } }
From source file:net.vexelon.currencybg.app.ui.activities.MainActivity.java
private void setupDrawerContent(NavigationView navigationView) { final Context context = this; navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override//from ww w.j a v a 2s . c o m public boolean onNavigationItemSelected(MenuItem menuItem) { if (menuItem.getItemId() == R.id.nav_settings) { // special case -> settings PreferenceFragmentCompat fragment = new PrefsFragment(); FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment).commit(); menuItem.setChecked(true); setTitle(menuItem.getTitle()); drawerLayout.closeDrawers(); } else { selectDrawerItem(menuItem, getClassFromMenu(menuItem)); } return true; } }); }
From source file:com.meetingninja.csse.meetings.MeetingsFragment.java
@Override public boolean onContextItemSelected(MenuItem item) { int position = item.getItemId(); boolean handled = false; AdapterContextMenuInfo aInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (item.getGroupId() == MainActivity.DrawerLabel.MEETINGS.getPosition()) { switch (item.getOrder()) { case 1: // Edit Toast.makeText(getActivity(), item.getTitle(), Toast.LENGTH_SHORT).show(); handled = true;// w w w . j a va 2s . com break; case 2: // Delete Meeting meeting = meetingAdpt.getItem(position); // mySQLiteAdapter.deleteMeeting(meeting); Need to implement MeetingVolleyAdapter.deleteMeeting(meeting.getID()); meetings.remove(position); meetingAdpt.notifyDataSetChanged(); handled = true; break; default: Log.wtf(TAG, "Invalid context menu option selected"); break; } } else { Log.wtf(TAG, "What happened here?"); } return handled; }
From source file:io.ordunaleon.lumios.ui.DrawerActivity.java
@Override public boolean onNavigationItemSelected(MenuItem menuItem) { mDrawerLayout.closeDrawers();//ww w . j av a 2 s. c o m Fragment fragment; switch (menuItem.getItemId()) { case R.id.drawer_item_main: fragment = PriceListFragment.newInstance(); break; case R.id.drawer_item_settings: Intent i = new Intent(this, SettingsActivity.class); startActivity(i); return false; default: fragment = DummyFragment.newInstance(menuItem.getTitle()); break; } // Insert the fragment by replacing any existing fragment. FragmentManager fragmentManager = getSupportFragmentManager(); fragmentManager.beginTransaction().replace(R.id.frame_layout, fragment).commit(); // Highlight the selected item, update the title, and close the drawer. menuItem.setChecked(true); setTitle(menuItem.getTitle()); return true; }
From source file:com.alainesp.fan.sanderson.MainActivity.java
@Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (!item.isChecked()) { if (id != R.id.nav_about) { this.setTitle(item.getTitle()); item.setChecked(true);/*from w w w . j a v a 2s . c om*/ } if (id == R.id.nav_main) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new SummaryFragment()).commit(); app_state = APP_STATE_SUMMARY; } else if (id == R.id.nav_blog) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new BlogPostsFragment()) .commit(); app_state = APP_STATE_BLOG; } else if (id == R.id.nav_events) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new EventsFragment()).commit(); app_state = APP_STATE_EVENTS; } else if (id == R.id.nav_books) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new BooksFragment()).commit(); app_state = APP_STATE_BOOKS; } else if (id == R.id.nav_twitter) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TwitterFragment()).commit(); app_state = APP_STATE_TWITTER; } else if (id == R.id.nav_tor0) { Uri webpage = Uri.parse("http://www.tor.com/features/series/the-way-of-kings-reread-on-torcom/"); Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage); if (isIntentSafe(webIntent)) startActivity(webIntent); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TorWoKRereadFragment()) .commit(); app_state = APP_STATE_WOK; this.setTitle("The Way of Kings Reread"); } else if (id == R.id.nav_tor1) { //Uri webpage = Uri.parse("http://www.tor.com/series/words-of-radiance-reread-on-torcom/"); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new TorWoRRereadFragment()) .commit(); app_state = APP_STATE_WOR; this.setTitle("Words of Radiance Reread"); } else if (id == R.id.nav_17shard)// TODO: Handle posts and news in the app { Uri webpage = Uri.parse("http://www.17thshard.com/forum/"); Intent webIntent = new Intent(Intent.ACTION_VIEW, webpage); if (isIntentSafe(webIntent)) startActivity(webIntent); getFragmentManager().beginTransaction().replace(R.id.main_fragment, new Shard17thFragment()) .commit(); app_state = APP_STATE_17SHARD; } else if (id == R.id.nav_settings) { getFragmentManager().beginTransaction().replace(R.id.main_fragment, new SettingsFragment()) .commit(); app_state = APP_STATE_SETTINGS; } else if (id == R.id.nav_about) { try { new AlertDialog.Builder(this).setTitle("About") .setMessage(Html.fromHtml("<em>Fan of Sanderson</em> " + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + " BETA" + "<br/><br/>Application made by fans to fans.<br/><br/>" + "Developer: Alain Espinosa <alainesp@gmail.com>")) .setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create().show(); } catch (PackageManager.NameNotFoundException ignored) { } } } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
From source file:org.digitalcampus.oppia.activity.OppiaMobileActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection Log.d(TAG, "Menu item selected: " + item.getTitle()); final int itemId = item.getItemId(); AdminSecurityManager.checkAdminPermission(this, itemId, new AdminSecurityManager.AuthListener() { public void onPermissionGranted() { if (itemId == R.id.menu_download) { startActivity(new Intent(OppiaMobileActivity.this, TagSelectActivity.class)); } else if (itemId == R.id.menu_about) { startActivity(new Intent(OppiaMobileActivity.this, AboutActivity.class)); } else if (itemId == R.id.menu_monitor) { startActivity(new Intent(OppiaMobileActivity.this, MonitorActivity.class)); } else if (itemId == R.id.menu_scorecard) { startActivity(new Intent(OppiaMobileActivity.this, ScorecardActivity.class)); } else if (itemId == R.id.menu_search) { startActivity(new Intent(OppiaMobileActivity.this, SearchActivity.class)); } else if (itemId == R.id.menu_settings) { startPrefsActivity();//from w w w .j a va 2 s .c om } else if (itemId == R.id.menu_language) { createLanguageDialog(); } else if (itemId == R.id.menu_logout) { logout(); } } }); return true; }
From source file:pl.edu.agh.schedule.myschedule.MyScheduleActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = sp.edit(); editor.putBoolean(SettingsActivity.PREF_BEACON_SCAN_ENABLED, false); editor.apply();//from w w w .ja va 2s. co m onlineOfflineMode(); String newLocation = item.getTitle().toString(); location = newLocation; updateData(); setTitle(newLocation); return super.onOptionsItemSelected(item); }
From source file:joshuatee.wx.StormReportsActivity.java
@Override public boolean onContextItemSelected(MenuItem item) { if (((String) item.getTitle()).contains("Show N0Q from")) { RadarProdShow(item.getItemId(), "N0Q", true); } else if (((String) item.getTitle()).contains("Show N0U from")) { RadarProdShow(item.getItemId(), "N0U", true); }/*from w w w .j a v a2 s .com*/ else if (((String) item.getTitle()).contains("Show TR0 from")) { RadarProdShow(item.getItemId(), "TR0", true); } else if (((String) item.getTitle()).contains("Show TV0 from")) { RadarProdShow(item.getItemId(), "TV0", true); } else if (item.getTitle().equals("Show N0Q ( no blue dot )")) { RadarProdShow(item.getItemId(), "N0Q", false); } else if (item.getTitle().equals("Show N0U ( no blue dot )")) { RadarProdShow(item.getItemId(), "N0U", false); } else if (item.getTitle().equals("Show TR0 ( no blue dot )")) { RadarProdShow(item.getItemId(), "TR0", false); } else if (item.getTitle().equals("Show TV0 ( no blue dot )")) { RadarProdShow(item.getItemId(), "TV0", false); } else { return false; } return true; }
From source file:com.github.rubensousa.navigationmanager.NavigationManager.java
@Override public boolean onNavigationItemSelected(MenuItem item) { if (mNavigationListener != null) { mNavigationListener.onItemSelected(item); }/*from w ww . ja v a 2 s.c o m*/ closeDrawer(); boolean firstStart = mCurrentId == 0; if (item.getItemId() == mCurrentId) { mNavigating = false; return false; } mCurrentId = item.getItemId(); mTitle = item.getTitle().toString(); // If an item is checkable, then a fragment should be used if (item.isCheckable()) { mNavigationView.setCheckedItem(mCurrentId); if (mNavigationListener != null && mCurrentFragment != null) { mNavigationListener.onSectionChange(mCurrentFragment); } mCurrentFragment = createFragment(item.getItemId()); // Check if we have an Intent to pass to the fragment if (mIntent != null) { Bundle args = mCurrentFragment.getArguments(); Bundle extras = mIntent.getExtras(); // If no arguments were passed to the fragment, the bundle must be created if (args == null) { args = new Bundle(); } // Add the fragment's arguments to the new Intent if (extras != null) { args.putAll(extras); } mCurrentFragment.setArguments(args); mIntent = null; } if (!shouldDelayTransaction(mCurrentId) || firstStart || mNavigating) { commitFragmentTransaction(createFragmentTransaction(mCurrentFragment)); } else { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); mFragmentTransaction = createFragmentTransaction(mCurrentFragment); } mNavigating = false; return true; } mNavigating = false; return false; }
From source file:com.arvention.lavish.activity.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); toiletArrayList = new ArrayList<>(); // Create an instance of GoogleAPIClient. if (mGoogleApiClient == null) { // ATTENTION: This "addApi(AppIndex.API)"was auto-generated to implement the App Indexing API. // See https://g.co/AppIndexing/AndroidStudio for more information. mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(LocationServices.API).addApi(AppIndex.API) .build();/*from w w w . j a v a 2 s. c om*/ } // Obtain the SupportMapFragment and get notified when the map is ready to be used. SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); navigationView = (NavigationView) findViewById(R.id.navigation_view); navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { int index = 0; for (int i = 0; i < menu.length; i++) { if (menu[i].equals(item.getTitle())) index = i; } Intent intent = new Intent(getApplicationContext(), DisplayAllToiletsActivity.class); intent.putExtra("FEATURE", features[index]); startActivity(intent); return true; } }); recognizer = SphinxRecognizer.getInstance(this); recognizer.addInterpreter(this); buttonRate = (Button) findViewById(R.id.main_rate_button); buttonRate.setOnClickListener(new Button.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getApplicationContext(), RateActivity.class); startActivity(intent); } }); panelflipper = (ViewFlipper) findViewById(R.id.panel_container); }