List of usage examples for android.widget PopupMenu setOnMenuItemClickListener
public void setOnMenuItemClickListener(OnMenuItemClickListener listener)
From source file:com.vrs.reqdroid.fragments.HipotesesFragment.java
/** * Mostra o PopUpMenu das opcoes da hipotese * Funciona apenas para a versao 3.0 ou superior do Android. * * @param v a view da hipotese//from w w w .j av a2 s . co m * */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) void exibePopupMenuOpcoes(final View v) { PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.menu_opcoes_hipotese, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.opcaoEditarHipotese: menuEdita(); break; case R.id.opcaoValidarHipotese: menuValida(); break; case R.id.opcaoDeletarHipotese: menuDeleta(); break; } return true; } }); popupMenu.show(); }
From source file:com.lovejoy777sarootool.rootool.fragments.BrowserFragment.java
private void showMenu(View v) { PopupMenu popup = new PopupMenu(mActivity, v); // This activity implements OnMenuItemClickListener popup.setOnMenuItemClickListener(this); popup.inflate(R.menu.fab_menu);//from w w w .ja v a 2 s.c o m popup.show(); }
From source file:com.cyanogenmod.eleven.utils.PopupMenuHelper.java
/** * Call this to inflate and show the pop up menu * @param view the view to anchor the popup menu against * @param position the item that was clicked in the popup menu (or -1 if not relevant) */// w w w . j a va 2 s .c o m public void showPopupMenu(final View view, final int position) { // create the popup menu PopupMenu popupMenu = new PopupMenu(mActivity, view); final Menu menu = popupMenu.getMenu(); // hook up the click listener popupMenu.setOnMenuItemClickListener(this); // figure what type of pop up menu it is mType = onPreparePopupMenu(position); if (mType != null) { // inflate the menu createPopupMenu(menu); // show it popupMenu.show(); } }
From source file:com.android.deskclock.DeskClock.java
private void showMenu(View v) { PopupMenu popupMenu = new PopupMenu(this, v); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from w w w .j a v a2s . c om public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_item_settings: startActivity(new Intent(DeskClock.this, SettingsActivity.class)); return true; case R.id.menu_item_help: Intent i = item.getIntent(); if (i != null) { try { startActivity(i); } catch (ActivityNotFoundException e) { // No activity found to match the intent - ignore } } return true; case R.id.menu_item_night_mode: startActivity(new Intent(DeskClock.this, ScreensaverActivity.class)); default: break; } return true; } }); popupMenu.inflate(R.menu.desk_clock_menu); Menu menu = popupMenu.getMenu(); MenuItem help = menu.findItem(R.id.menu_item_help); if (help != null) { Utils.prepareHelpMenuItem(this, help); } popupMenu.show(); }
From source file:de.schildbach.wallet.ui.monitor.BlockListFragment.java
@Override public void onBlockMenuClick(final View view, final Sha256Hash blockHash) { final PopupMenu popupMenu = new PopupMenu(activity, view); popupMenu.inflate(R.menu.blocks_context); popupMenu.getMenu().findItem(R.id.blocks_context_browse).setVisible(Constants.ENABLE_BROWSE); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override/*from w w w . j a va2 s . c om*/ public boolean onMenuItemClick(final MenuItem item) { switch (item.getItemId()) { case R.id.blocks_context_browse: final Uri blockExplorerUri = config.getBlockExplorer(); log.info("Viewing block {} on {}", blockHash, blockExplorerUri); startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(blockExplorerUri, "block/" + blockHash))); return true; } return false; } }); popupMenu.show(); }
From source file:com.dgsd.android.ShiftTracker.Fragment.WeekFragment.java
@Override public void onItemClick(AdapterView<?> list, final View view, int pos, long id) { final WeekAdapter.ViewHolder holder = (WeekAdapter.ViewHolder) view.getTag(); final Intent intent = getIntentFor(holder); if (!mHasTemplates || (holder != null && holder.shift != null)) { startActivity(intent);//w ww . jav a 2s. c o m return; } final int jd = holder == null ? -1 : holder.julianDay; if (Api.isMin(Api.HONEYCOMB)) { PopupMenu popup = new PopupMenu(getActivity(), view.findViewById(R.id.text)); popup.getMenuInflater().inflate(R.menu.week_list_item_popup, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { if (item.getItemId() == R.id.template_shift) { showTemplateChooser(jd); } else if (item.getItemId() == R.id.new_shift) { startActivity(intent); } return false; } }); popup.show(); } else { mList.showContextMenuForChild(view); } }
From source file:com.owncloud.android.ui.adapter.UserListAdapter.java
private void onOverflowIconClicked(View view, AppCompatCheckBox allowEditsCheckBox, OCShare share) { // use grey as fallback for elements where custom theming is not available if (ThemeUtils.themingEnabled(context)) { context.getTheme().applyStyle(R.style.FallbackThemingTheme, true); }/*ww w. jav a 2 s . c om*/ PopupMenu popup = new PopupMenu(context, view); popup.inflate(R.menu.file_detail_sharing_menu); prepareOptionsMenu(popup.getMenu(), share); popup.setOnMenuItemClickListener( item -> optionsItemSelected(popup.getMenu(), item, allowEditsCheckBox, share)); popup.show(); }
From source file:org.lytsing.android.weibo.ui.ComposeActivity.java
@Override public void onClick(View view) { int viewId = view.getId(); if (viewId == android.R.id.home) { NavUtils.navigateUpFromSameTask(this); return;// w ww . ja v a 2 s . c o m } if (viewId == R.id.ll_text_limit_unit) { mContent = mEdit.getText().toString(); if (TextUtils.isEmpty(mContent)) return; DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mEdit.setText(""); } }; AlertUtil.showAlert(this, R.string.attention, R.string.delete_all, getString(R.string.ok), listener, getString(R.string.cancel), null); } else if (viewId == R.id.ib_insert_pic) { PopupMenu popup = new PopupMenu(this, view); popup.getMenuInflater().inflate(R.menu.pic, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(android.view.MenuItem item) { Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_GET_CONTENT); galleryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(galleryIntent, 2); return true; } }); popup.show(); } else if (viewId == R.id.ib_face_keyboard) { showOrHideIMM(); } else if (viewId == R.id.ib_insert_location) { if (mIsLocation) { aq.id(R.id.tv_location).gone(); aq.id(R.id.ib_insert_location).image(R.drawable.btn_insert_location_nor); mIsLocation = false; mLatitude = ""; mLongitude = ""; } else { aq.id(R.id.ly_loadlocation).visible(); location_ajax(); } } }
From source file:com.arcgis.android.samples.localdata.localrasterdata.FileBrowserFragment.java
private void initializeFileListView() { ListView lView = (ListView) (getView().findViewById(R.id.fileListView)); lView.setBackgroundColor(Color.LTGRAY); LinearLayout.LayoutParams lParam = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);//from www.ja v a 2 s . c om lParam.setMargins(15, 5, 15, 5); lView.setAdapter(this.adapter); lView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { chosenFile = fileList.get(position).file; final File sel = new File(path + "/" + chosenFile); if (sel.isDirectory()) { // Directory if (sel.canRead()) { // Adds chosen directory to list pathDirsList.add(chosenFile); path = new File(sel + ""); loadFileList(); adapter.notifyDataSetChanged(); updateCurrentDirectoryTextView(); } else { showToast("Path does not exist or cannot be read"); } } else { // File picked or an empty directory message clicked if (!mDirectoryShownIsEmpty) { // show a popup menu to allow users to open a raster layer for // different purpose including basemap layer, operational layer, // elevation data source for BlendRenderer, or some combinations. PopupMenu popupMenu = new PopupMenu(getActivity(), view); popupMenu.inflate(R.menu.file_browser_popup_menu); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_raster_base_layer: returnFileFinishActivity(sel.getAbsolutePath(), RasterLayerAction.BASEMAP_LAYER); break; case R.id.menu_raster_operational_layer: returnFileFinishActivity(sel.getAbsolutePath(), RasterLayerAction.OPERATIONAL_LAYER); break; case R.id.menu_raster_elevation_source: returnFileFinishActivity(sel.getAbsolutePath(), RasterLayerAction.ELEVATION_SOURCE); break; case R.id.menu_raster_base_elevation: returnFileFinishActivity(sel.getAbsolutePath(), RasterLayerAction.BASEMAP_LAYER_AND_ELEVATION_SOURCE); break; case R.id.menu_raster_operational_elevation: returnFileFinishActivity(sel.getAbsolutePath(), RasterLayerAction.OPERATIONAL_LAYER_AND_ELEVATION_SOURCE); break; } return true; } }); popupMenu.show(); } } } }); }
From source file:org.alfresco.mobile.android.application.fragments.site.browser.SiteAdapter.java
@Override protected void updateTopText(TwoLinesViewHolder vh, Site item) { super.updateTopText(vh, item); if (mode == ListingModeFragment.MODE_IMPORT || mode == ListingModeFragment.MODE_PICK) { UIUtils.setBackground(vh.choose, null); return;// w w w . ja v a2 s. c om } vh.choose.setImageResource(R.drawable.ic_more_options); vh.choose.setBackgroundResource(R.drawable.alfrescohololight_list_selector_holo_light); int d_16 = DisplayUtils.getPixels(getContext(), R.dimen.d_16); vh.choose.setPadding(d_16, d_16, d_16, d_16); vh.choose.setVisibility(View.VISIBLE); AccessibilityUtils.addContentDescription(vh.choose, String.format(getContext().getString(R.string.more_options_site), item.getTitle())); vh.choose.setTag(R.id.site_action, item); vh.choose.setOnClickListener(new OnClickListener() { @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onClick(View v) { Site item = (Site) v.getTag(R.id.site_action); selectedOptionItems.add(item); PopupMenu popup = new PopupMenu(getContext(), v); getMenu(popup.getMenu(), item); popup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { selectedOptionItems.clear(); } }); popup.setOnMenuItemClickListener(SiteAdapter.this); popup.show(); } }); }