android.view.MenuItem Java Examples
The following examples show how to use
android.view.MenuItem.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MainActivity.java From SmartProxy with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.main_activity_actions, menu); MenuItem menuItem = menu.findItem(R.id.menu_item_switch); if (menuItem == null) { return false; } switchProxy = (Switch) menuItem.getActionView(); if (switchProxy == null) { return false; } switchProxy.setChecked(LocalVpnService.IsRunning); switchProxy.setOnCheckedChangeListener(this); return true; }
Example #2
Source File: CardFlipActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // Navigate "up" the demo structure to the launchpad activity. // See http://developer.android.com/design/patterns/navigation.html for more. NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class)); return true; case R.id.action_flip: flipCard(); return true; } return super.onOptionsItemSelected(item); }
Example #3
Source File: MainActivity.java From PagerTabIndicator with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.text: changeTabAdapter(TabAdapterType.TEXT); break; case R.id.image: changeTabAdapter(TabAdapterType.IMAGE); break; case R.id.web: changeTabAdapter(TabAdapterType.WEB); break; case R.id.custom: changeTabAdapter(TabAdapterType.CUSTOM); break; case R.id.custom_anim: changeTabAdapter(TabAdapterType.CUSTOM_ANIM); break; } return true; }
Example #4
Source File: SearchBookActivity.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id) { case R.id.action_book_source_manage: BookSourceActivity.startThis(this, requestSource); break; case android.R.id.home: SoftInputUtil.hideIMM(getCurrentFocus()); finish(); break; default: if (item.getGroupId() == R.id.source_group) { item.setChecked(true); if (Objects.equals(getString(R.string.all_source), item.getTitle().toString())) { MApplication.SEARCH_GROUP = null; } else { MApplication.SEARCH_GROUP = item.getTitle().toString(); } mPresenter.initSearchEngineS(MApplication.SEARCH_GROUP); } } return super.onOptionsItemSelected(item); }
Example #5
Source File: AllTracksFragment.java From odyssey with GNU General Public License v3.0 | 6 votes |
/** * Hook called when an menu item in the context menu is selected. * * @param item The menu item that was selected. * @return True if the hook was consumed here. */ @Override public boolean onContextItemSelected(@NonNull MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); if (info == null) { return super.onContextItemSelected(item); } switch (item.getItemId()) { case R.id.fragment_all_tracks_action_enqueue: enqueueTrack(info.position, false); return true; case R.id.fragment_all_tracks_action_enqueueasnext: enqueueTrack(info.position, true); return true; case R.id.fragment_all_tracks_action_play: playTrack(info.position, false); return true; case R.id.fragment_all_tracks_showartist: showArtist(info.position); return true; default: return super.onContextItemSelected(item); } }
Example #6
Source File: MainActivity.java From BrokenView with MIT License | 6 votes |
private void initToolbar(){ toolbar = (Toolbar) this.findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_refresh: mBrokenView.reset(); refreshDate(); setOnTouchListener(); setViewVisible(); break; } return true; } }); }
Example #7
Source File: MainActivity.java From MultiStateView with Apache License 2.0 | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); if (id == R.id.nav_camera) { // Handle the camera action } else if (id == R.id.nav_gallery) { } else if (id == R.id.nav_slideshow) { } else if (id == R.id.nav_manage) { } else if (id == R.id.nav_share) { } else if (id == R.id.nav_send) { } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #8
Source File: MainActivity.java From CoolChat with Apache License 2.0 | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.nav_menu_setting: startActivity(new Intent(MainActivity.this, SettingActivity.class)); break; default: showToast("暂未开发"); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); startActivity(new Intent(MainActivity.this, TestActivity.class)); break; } return true; }
Example #9
Source File: UserDetailActivity.java From Ruisi with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.menu_add) { if (!App.isLogin(this)) { Snackbar.make(coordinatorLayout, "你还没有登录,无法进行操作", Snackbar.LENGTH_LONG) .setAction("点我登录", view -> startActivity(new Intent(getApplicationContext(), LoginActivity.class))).show(); } else { AddFriendDialog dialogFragment = AddFriendDialog.newInstance( this, username, imageUrl); dialogFragment.show(getSupportFragmentManager(), "add"); } } return super.onOptionsItemSelected(item); }
Example #10
Source File: SwipeRefreshLayoutBasicFragment.java From android-SwipeRefreshLayoutBasic with Apache License 2.0 | 6 votes |
/** * Respond to the user's selection of the Refresh action item. Start the SwipeRefreshLayout * progress bar, then initiate the background task that refreshes the content. */ @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_refresh: Log.i(LOG_TAG, "Refresh menu item selected"); // We make sure that the SwipeRefreshLayout is displaying it's refreshing indicator if (!mSwipeRefreshLayout.isRefreshing()) { mSwipeRefreshLayout.setRefreshing(true); } // Start our refresh background task initiateRefresh(); return true; } return super.onOptionsItemSelected(item); }
Example #11
Source File: PicSelectActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int itemId = item.getItemId(); if (itemId == android.R.id.home) { this.finish(); return true; } else if (itemId == R.id.action_complete) { complete(); return true; } // case R.id.action_more: // // Get the ActionProvider for later usage // provider = (MoreActionProvider) menu.findItem(R.id.menu_share) // .getActionProvider(); // return true; return super.onOptionsItemSelected(item); }
Example #12
Source File: FriendsFragment.java From Abelana-Android with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); //Uses a built-in Android intent to display email addresses from your contacts if (id == R.id.action_find_friends) { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); intent.setType(ContactsContract.CommonDataKinds.Email.CONTENT_TYPE); startActivityForResult(intent, PICK_CONTACT_REQUEST); } /* Alternatively, the user can manually input an email address of a friend they'd like to follow. * Note, currently the user must already have the app for the follow to work. */ if (id == R.id.manual_friend_search) { showDialog(); } return super.onOptionsItemSelected(item); }
Example #13
Source File: Home.java From UberClone with MIT License | 6 votes |
@SuppressWarnings("StatementWithEmptyBody") @Override public boolean onNavigationItemSelected(MenuItem item) { // Handle navigation view item clicks here. int id = item.getItemId(); switch (id){ case R.id.nav_trip_history: showTripHistory(); break; case R.id.nav_updateInformation: showDialogUpdateInfo(); break; case R.id.nav_signOut: signOut(); break; } DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; }
Example #14
Source File: QuotesFragment.java From coursera-android with MIT License | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Show Toast Messages. Toast Messages are discussed in the lesson on user interface classes // return value true indicates that the menu click has been handled case R.id.detail_menu_item_main: Toast.makeText(getActivity().getApplicationContext(), "This action provided by the QuoteFragment", Toast.LENGTH_SHORT).show(); return true; case R.id.detail_menu_item_secondary: Toast.makeText(getActivity().getApplicationContext(), "This action is also provided by the QuoteFragment", Toast.LENGTH_SHORT).show(); return true; default: return super.onOptionsItemSelected(item); } }
Example #15
Source File: MainActivity.java From material-navigation-drawer with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. // AUTOMATICALLY ONLY ON 4.1+ !!! int id = item.getItemId(); if (id == android.R.id.home) { if (mDrawerToggle != null) return mDrawerToggle.onOptionsItemSelected(item); if (mSlidingLayout != null) { if (mSlidingLayout.isOpen()) mSlidingLayout.closePane(); else mSlidingLayout.openPane(); return true; } } return super.onOptionsItemSelected(item); }
Example #16
Source File: TagEditActivity.java From talk-android with MIT License | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish(); break; case R.id.action_done: final String text = mEditText.getText().toString().trim(); if (!TextUtils.isEmpty(text)) { mPresenter.updateTag(mTagId, text); } break; } return super.onOptionsItemSelected(item); }
Example #17
Source File: PermissionsActivity.java From APDE with GNU General Public License v2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { switch(item.getItemId()) { case android.R.id.home: if (isPreviewSetttings) { promptSaveDataPreviewSettings(); } else { finish(); } return true; case R.id.menu_new_permission: newPermission(); return true; case R.id.action_settings: launchSettings(); return true; default: return super.onOptionsItemSelected(item); } }
Example #18
Source File: TaskListActivity.java From batteryhub with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); //noinspection SimplifiableIfStatement if (id == R.id.action_settings) { startActivity(new Intent(this, SettingsActivity.class)); return true; } else if (id == R.id.action_sort_memory) { sortTasksBy(Config.SORT_BY_MEMORY, mSortOrderMemory); mSortOrderMemory = -mSortOrderMemory; return true; } else if (id == R.id.action_sort_name) { sortTasksBy(Config.SORT_BY_NAME, mSortOrderName); mSortOrderName = -mSortOrderName; return true; } return super.onOptionsItemSelected(item); }
Example #19
Source File: AlbumsFragment.java From RetroMusicPlayer with GNU General Public License v3.0 | 6 votes |
private boolean handleSortOrderMenuItem(@NonNull MenuItem item) { String sortOrder = null; switch (item.getItemId()) { case R.id.action_sort_order_album: sortOrder = AlbumSortOrder.ALBUM_A_Z; break; case R.id.action_sort_order_album_desc: sortOrder = AlbumSortOrder.ALBUM_Z_A; break; case R.id.action_sort_order_artist: sortOrder = AlbumSortOrder.ALBUM_ARTIST; break; } if (sortOrder != null) { item.setChecked(true); setSaveSortOrder(sortOrder); } return true; }
Example #20
Source File: VideoDetailsFragment.java From Loop with Apache License 2.0 | 6 votes |
@Override public boolean onOptionsItemSelected(final MenuItem item) { switch (item.getItemId()) { case R.id.share: if (video != null) { // EventLogger.fire(ProductShareEvent.start(mProduct.getId())); Intent sendIntent = new Intent(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_TEXT, String.format("I found this on Loop. Check it out.\n\n%s\n\n%s", video.getName(), video.getLink())); String title = getResources().getString(R.string.share_this_video); Intent chooser = Intent.createChooser(sendIntent, title); if (sendIntent.resolveActivity(getActivity().getPackageManager()) != null) { startActivityForResult(chooser, VIDEO_SHARE_REQUEST_CODE); } } return true; default: break; } return super.onOptionsItemSelected(item); }
Example #21
Source File: MemberListActivity.java From tapchat-android with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { long connectionId = getIntent().getLongExtra(BufferFragment.ARG_CONNECTION_ID, -1); long bufferId = getIntent().getLongExtra(BufferFragment.ARG_BUFFER_ID, -1); if (item.getItemId() == android.R.id.home) { Intent intent = new Intent(this, BuffersActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setData(Uri.parse(String.format("tapchat://%s/%s", connectionId, bufferId))); startActivity(intent); return true; } return false; }
Example #22
Source File: MainActivity.java From BooheeScrollView with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); switch (id){ case R.id.normal: booheeScrollView.setAnimType(BooheeScrollView.NORMAL_ANIM); break; case R.id.rebound: booheeScrollView.setAnimType(BooheeScrollView.REBOUND_ANIM); break; } return true; }
Example #23
Source File: ChatRoomActivity.java From my-first-realm-app with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_logout) { SyncUser syncUser = SyncUser.current(); if (syncUser != null) { syncUser.logOut(); Intent intent = new Intent(this, WelcomeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); } return true; } return super.onOptionsItemSelected(item); }
Example #24
Source File: MainActivity.java From TemplateAppProject with Apache License 2.0 | 5 votes |
/** * 处理侧边栏点击事件 * * @param menuItem * @return */ private boolean handleNavigationItemSelected(@NonNull MenuItem menuItem) { int index = CollectionUtils.arrayIndexOf(mTitles, menuItem.getTitle()); if (index != -1) { toolbar.setTitle(menuItem.getTitle()); viewPager.setCurrentItem(index, false); return true; } return false; }
Example #25
Source File: MainActivity.java From animation-samples with Apache License 2.0 | 5 votes |
@Override public boolean onPrepareOptionsMenu(Menu menu) { MenuItem logToggle = menu.findItem(R.id.menu_toggle_log); logToggle.setVisible(findViewById(R.id.sample_output) instanceof ViewAnimator); logToggle.setTitle(mLogShown ? R.string.sample_hide_log : R.string.sample_show_log); return super.onPrepareOptionsMenu(menu); }
Example #26
Source File: MapClickEventActivity.java From android-map-sdk with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); return true; } return super.onOptionsItemSelected(item); }
Example #27
Source File: DetailActivity.java From Game-of-Thrones with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { onBackPressed(); } return true; }
Example #28
Source File: BasicActivity.java From intra42 with Apache License 2.0 | 5 votes |
/** * Called when an item in the navigation menu is selected. * * @param item The selected item * @return true to display the item as the selected item */ @Override public boolean onNavigationItemSelected(@NonNull MenuItem item) { Navigation.onNavigationItemSelected(this, item); drawer.closeDrawer(GravityCompat.START); return true; }
Example #29
Source File: ChatRoomActivity.java From MessagingAndroidChat with MIT License | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }
Example #30
Source File: TimelineActivity.java From twittererer with Apache License 2.0 | 5 votes |
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_tweet) { showNewTweetDialog(); return true; } return super.onOptionsItemSelected(item); }