android.view.MenuItem.OnMenuItemClickListener Java Examples
The following examples show how to use
android.view.MenuItem.OnMenuItemClickListener.
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: UserContextMenuListener.java From YiBo with Apache License 2.0 | 7 votes |
private void analyzeUserMenu(final Adapter adapter, final User user, ContextMenu menu, final Context context) { menu.setHeaderTitle(R.string.menu_title_blog); int order = 0; MenuItem commentMenu = menu.add(0, 1, order++, R.string.menu_group_member_user_profile); Intent commentIntent = new Intent(context, ProfileActivity.class); commentIntent.putExtra("USER", user); commentMenu.setIntent(commentIntent); MenuItem unfollowMenu = menu.add(0, 2, order++, R.string.menu_group_member_unfollow); unfollowMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { CacheAdapter<User> cacheAdapter = (CacheAdapter<User>)AdapterUtil.getCacheAdapter(adapter); GroupMemberUnfollowTask task = new GroupMemberUnfollowTask(cacheAdapter, user); task.execute(); return false; } }); MenuItem messageMenu = menu.add(0, 2, order++, R.string.menu_group_member_message); Intent messageIntent = new Intent(context, EditDirectMessageActivity.class); messageIntent.putExtra("DISPLAY_NAME", user.getDisplayName()); messageMenu.setIntent(messageIntent); }
Example #2
Source File: VectorMapSampleBaseActivity.java From hellomap3d-android with MIT License | 7 votes |
private void addStyleMenuOption(final Menu menu, String text, final String value) { MenuItem menuItem = menu.add(text).setOnMenuItemClickListener(new OnMenuItemClickListener(){ @Override public boolean onMenuItemClick (MenuItem item){ for (int i = 0; i < menu.size(); i++) { MenuItem otherItem = menu.getItem(i); if (otherItem == item) { otherItem.setIcon(android.R.drawable.checkbox_on_background); } else { otherItem.setIcon(null); } } vectorStyleName = value; updateBaseLayer(); return true; } }); if (vectorStyleName.equals(value)) { menuItem.setIcon(android.R.drawable.checkbox_on_background); } }
Example #3
Source File: VectorMapSampleBaseActivity.java From hellomap3d-android with MIT License | 7 votes |
private void addLanguageMenuOption(final Menu menu, String text, final String value) { MenuItem menuItem = menu.add(text).setOnMenuItemClickListener(new OnMenuItemClickListener(){ @Override public boolean onMenuItemClick (MenuItem item){ for (int i = 0; i < menu.size(); i++) { MenuItem otherItem = menu.getItem(i); if (otherItem == item) { otherItem.setIcon(android.R.drawable.checkbox_on_background); } else { otherItem.setIcon(null); } } vectorStyleLang = value; updateBaseLayer(); return true; } }); if (vectorStyleLang.equals(value)) { menuItem.setIcon(android.R.drawable.checkbox_on_background); } }
Example #4
Source File: AccessTokenListFragment.java From DeviceConnect-Android with MIT License | 6 votes |
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { menu.clear(); // ActionBarの全削除ボタンを追加 final MenuItem menuItem = menu.add(R.string.delete_all); menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); menuItem.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { if (item.getTitle().equals(menuItem.getTitle())) { deleteAllTokenProc(); } return true; } }); }
Example #5
Source File: ProfileActivity.java From GeoLog with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { menu. add(R.string.menu_done). setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { finish(); return false; } }). setIcon(R.drawable.ic_action_done). setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); return true; }
Example #6
Source File: ActivityHome.java From gsn with GNU General Public License v3.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { final MenuItem add = menu.add("Quit TinyGSN"); add.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(final MenuItem item) { finish(); return true; } }); return super.onCreateOptionsMenu(menu); }
Example #7
Source File: SettingsActivity.java From MaterialPreferenceLibrary with Apache License 2.0 | 6 votes |
private static void setOnMenuItemClickListenerRecursive(Menu menu, OnMenuItemClickListener listener) { List<Menu> menus = new ArrayList<>(1); menus.add(menu); while (!menus.isEmpty()) { final Menu currentMenu = menus.remove(0); for (int i = 0; i < currentMenu.size(); ++i) { final MenuItem item = currentMenu.getItem(i); item.setOnMenuItemClickListener(listener); final SubMenu subMenu = item.getSubMenu(); if (subMenu != null) menus.add(subMenu); } } }
Example #8
Source File: SettingsActivity.java From MaterialPreferenceLibrary with Apache License 2.0 | 6 votes |
private void handleActionBarMenu() { getToolbar().inflateMenu(R.menu.activity_main); final OnMenuItemClickListener onMenuItemClickListener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(final MenuItem item) { String url = null; switch (item.getItemId()) { case R.id.menuItem_all_my_apps: url = "https://play.google.com/store/apps/developer?id=AndroidDeveloperLB"; break; case R.id.menuItem_all_my_repositories: url = "https://github.com/AndroidDeveloperLB"; break; case R.id.menuItem_current_repository_website: url = "https://github.com/AndroidDeveloperLB/MaterialPreferenceLibrary"; break; } if (url == null) return true; final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK); startActivity(intent); return true; } }; setOnMenuItemClickListenerRecursive(getToolbar().getMenu(), onMenuItemClickListener); }
Example #9
Source File: PackageManagerActivity.java From hellomap3d-android with MIT License | 6 votes |
@SuppressLint({ "InlinedApi", "NewApi" }) @Override public boolean onCreateOptionsMenu(Menu menu) { MenuItem menuItem = menu.add("Map").setOnMenuItemClickListener(new OnMenuItemClickListener(){ @Override public boolean onMenuItemClick (MenuItem item){ // Using static global variable to pass data. Avoid this in your app (memory leaks etc)! PackageManagerActivity.dataSource = new PackageManagerTileDataSource(PackageManagerActivity.this.packageManager); Intent myIntent = new Intent(PackageManagerActivity.this, PackagedMapActivity.class); PackageManagerActivity.this.startActivity(myIntent); return true; } }); menuItem.setIcon(android.R.drawable.ic_dialog_map); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); } return super.onCreateOptionsMenu(menu); }
Example #10
Source File: Form.java From appinventor-extensions with Apache License 2.0 | 6 votes |
public void addExitButtonToMenu(Menu menu) { MenuItem stopApplicationItem = menu.add(Menu.NONE, Menu.NONE, Menu.FIRST, "Stop this application") .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { showExitApplicationNotification(); return true; } }); stopApplicationItem.setIcon(android.R.drawable.ic_notification_clear_all); }
Example #11
Source File: RecentTabsRowAdapter.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override void onCreateContextMenuForChild(final int childPosition, ContextMenu menu, Activity activity) { if (isMoreButton(childPosition)) return; OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.closeTab(getChild(childPosition)); return true; } }; menu.add(R.string.close_tab).setOnMenuItemClickListener(listener); }
Example #12
Source File: RecentTabsRowAdapter.java From delion with Apache License 2.0 | 6 votes |
@Override public void onCreateContextMenuForChild(int childPosition, ContextMenu menu, Activity activity) { final ForeignSessionTab foreignSessionTab = getChild(childPosition); OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab, WindowOpenDisposition.NEW_BACKGROUND_TAB); return true; } }; menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener); }
Example #13
Source File: RecentTabsRowAdapter.java From delion with Apache License 2.0 | 6 votes |
@Override void onCreateContextMenuForChild(final int childPosition, ContextMenu menu, Activity activity) { if (isMoreButton(childPosition)) return; OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.closeTab(getChild(childPosition)); return true; } }; menu.add(R.string.close_tab).setOnMenuItemClickListener(listener); }
Example #14
Source File: ReplForm.java From appinventor-extensions with Apache License 2.0 | 6 votes |
public void addLogcatButton(Menu menu) { if (!ReplApplication.isAcraActive()) { // If ACRA isn't active return; // we don't show the button } MenuItem showSettingsItem = menu.add(Menu.NONE, Menu.NONE, 4, "Send Error Report").setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { String reportId = genReportId(); ReplApplication.reportError(null, reportId); Notifier.oneButtonAlert(activeForm, "Your Report Id is: " + reportId + "<br />Use this ID when reporting this error.", "Error Report Id", "OK"); return true; } }); showSettingsItem.setIcon(android.R.drawable.stat_sys_warning); }
Example #15
Source File: ReplForm.java From appinventor-extensions with Apache License 2.0 | 6 votes |
public void addSettingsButton(Menu menu) { MenuItem showSettingsItem = menu.add(Menu.NONE, Menu.NONE, 3, "Settings").setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { PhoneStatus.doSettings(); return true; } }); showSettingsItem.setIcon(android.R.drawable.sym_def_app_icon); }
Example #16
Source File: Form.java From appinventor-extensions with Apache License 2.0 | 6 votes |
public void addAboutInfoToMenu(Menu menu) { MenuItem aboutAppItem = menu.add(Menu.NONE, Menu.NONE, 2, "About this application") .setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { showAboutApplicationNotification(); return true; } }); aboutAppItem.setIcon(android.R.drawable.sym_def_app_icon); }
Example #17
Source File: ForumFilterProvider.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public void setOnMenuItemClickListener(OnMenuItemClickListener listener) { mListener = listener; }
Example #18
Source File: RecentTabsRowAdapter.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenuForChild(int childPosition, ContextMenu menu, Activity activity) { final ForeignSessionTab foreignSessionTab = getChild(childPosition); OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab, WindowOpenDisposition.NEW_BACKGROUND_TAB); return true; } }; menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener); }
Example #19
Source File: RecentTabsRowAdapter.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onCreateContextMenuForChild(int childPosition, ContextMenu menu, Activity activity) { final ForeignSessionTab foreignSessionTab = getChild(childPosition); OnMenuItemClickListener listener = new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { mRecentTabsManager.openForeignSessionTab(mForeignSession, foreignSessionTab, WindowOpenDisposition.NEW_BACKGROUND_TAB); return true; } }; menu.add(R.string.contextmenu_open_in_new_tab).setOnMenuItemClickListener(listener); }
Example #20
Source File: SettingsActivity.java From AppOpsXposed with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { if(Util.isSystemApp(this)) { menu.add(R.string.uninstall) .setIcon(android.R.drawable.ic_menu_delete) .setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { final AlertDialog.Builder ab = new AlertDialog.Builder(SettingsActivity.this); ab.setMessage(getString(R.string.uninstall) + "? " + getString(R.string.will_reboot)); ab.setNegativeButton(android.R.string.cancel, null); ab.setPositiveButton(android.R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if(!SU.available()) { Toast.makeText(SettingsActivity.this, R.string.toast_needs_root, Toast.LENGTH_SHORT).show(); } else { final String[] commands = { "mount -o remount,rw /system", "rm " + LauncherActivity.SYSTEM_APK, "mount -o remount,ro /system", "sync", "reboot", }; Toast.makeText(SettingsActivity.this, R.string.will_reboot, Toast.LENGTH_LONG).show(); Util.runAsSu(commands); } } }); ab.show(); return true; } }) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } return true; }
Example #21
Source File: MostVisitedItem.java From delion with Apache License 2.0 | 2 votes |
/** * Allows the manager to add context menu items for a given MostVisitedItem. * @param menu The context menu that should be used to add menu items. * @param listener Listener that should get the callbacks for context menu selections. */ void onCreateContextMenu(ContextMenu menu, OnMenuItemClickListener listener);