List of usage examples for android.widget PopupMenu getMenu
public Menu getMenu()
From source file:com.siva.animation_sample.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); //getActionBar().setIcon(new ColorDrawable(getResources().getColor(android.R.color.transparent))); getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); getActionBar().setDisplayShowCustomEnabled(true); getActionBar().setCustomView(R.layout.custom_action_bar_layout); custom_action_view = getActionBar().getCustomView(); ImageView more_icon = (ImageView) custom_action_view.findViewById(R.id.moreimage); more_icon.setOnClickListener(new View.OnClickListener() { @Override/*from w w w . ja v a2 s.c o m*/ public void onClick(View v) { // TODO Auto-generated method stub PopupMenu popup = new PopupMenu(HomeActivity.this, v); MenuInflater inflate = popup.getMenuInflater(); inflate.inflate(R.menu.home, popup.getMenu()); popup.show(); popup.setOnMenuItemClickListener(HomeActivity.this); } }); mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost); mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent); Create_alert_box(); mTabHost.addTab( mTabHost.newTabSpec("tab1").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)), FragmentTab1.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab2").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)), FragmentTab2.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab3").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)), FragmentTab3.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab4").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)), FragmentTab4.class, null); mTabHost.addTab( mTabHost.newTabSpec("tab5").setIndicator(null, getResources().getDrawable(R.drawable.ic_launcher)), FragmentTab5.class, null); mTabHost.setCurrentTab(2); }
From source file:org.alfresco.mobile.android.application.fragments.fileexplorer.LibraryCursorAdapter.java
@Override protected void updateIcon(TwoLinesViewHolder vh, Cursor cursor) { String data = cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA)); File f = new File(data); switch (mediaTypeId) { case MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE: vh.icon.setImageResource(R.drawable.mime_img); renditionManager.getPicasso().load(f).resize(150, 150).centerCrop().placeholder(R.drawable.mime_256_img) .error(R.drawable.mime_256_img).into(vh.icon); break;// w w w . ja va 2 s . co m case MediaStore.Files.FileColumns.MEDIA_TYPE_VIDEO: vh.icon.setImageResource(R.drawable.mime_video); break; case MediaStore.Files.FileColumns.MEDIA_TYPE_AUDIO: vh.icon.setImageResource(R.drawable.mime_audio); break; default: Uri uri = Uri.parse(cursor.getString(cursor.getColumnIndex(MediaStore.Files.FileColumns.DATA))); vh.icon.setImageResource(MimeTypeManager.getInstance(context).getIcon(uri.getLastPathSegment())); break; } if (mode == FileExplorerFragment.MODE_LISTING && fragmentRef.get().getActivity() instanceof MainActivity) { vh.choose.setImageResource(R.drawable.ic_more_options); vh.choose.setBackgroundResource(R.drawable.alfrescohololight_list_selector_holo_light); int d_16 = DisplayUtils.getPixels(context, R.dimen.d_16); vh.choose.setPadding(d_16, d_16, d_16, d_16); vh.choose.setVisibility(View.VISIBLE); vh.choose.setTag(R.id.node_action, f); vh.choose.setOnClickListener(new OnClickListener() { @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) @Override public void onClick(View v) { File item = (File) v.getTag(R.id.node_action); selectedOptionItems.add(item); PopupMenu popup = new PopupMenu(context, v); getMenu(popup.getMenu(), item); popup.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(PopupMenu menu) { selectedOptionItems.clear(); } }); popup.setOnMenuItemClickListener(LibraryCursorAdapter.this); popup.show(); } }); } else { UIUtils.setBackground(vh.choose, null); vh.choose.setVisibility(View.GONE); } }
From source file:org.hawkular.client.android.fragment.FavTriggersFragment.java
private void showTriggerMenu(final View triggerView, final int triggerPosition) { PopupMenu triggerMenu = new PopupMenu(getActivity(), triggerView); triggerMenu.getMenuInflater().inflate(R.menu.popup_delete, triggerMenu.getMenu()); triggerMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*w w w . j a va2s. c om*/ public boolean onMenuItemClick(MenuItem menuItem) { Trigger trigger = getTriggersAdapter().getItem(triggerPosition); switch (menuItem.getItemId()) { case R.id.menu_delete: Context context = getActivity(); SQLStore<Trigger> store = openStore(context); store.openSync(); store.remove(trigger.getId()); onRefresh(); return true; default: return false; } } }); triggerMenu.show(); }
From source file:org.hawkular.client.android.fragment.FavMetricsFragment.java
private void showMetricMenu(final View metricView, final int metricPosition) { PopupMenu metricMenu = new PopupMenu(getActivity(), metricView); metricMenu.getMenuInflater().inflate(R.menu.popup_delete, metricMenu.getMenu()); metricMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*from w w w.ja va 2 s . c o m*/ public boolean onMenuItemClick(MenuItem menuItem) { Metric metric = getFavMetricsAdapter().getItem(metricPosition); switch (menuItem.getItemId()) { case R.id.menu_delete: Context context = getActivity(); SQLStore<Metric> store = openStore(context); store.openSync(); store.remove(metric.getId()); onRefresh(); return true; default: return false; } } }); metricMenu.show(); }
From source file:net.sf.golly.SettingsActivity.java
public void doPasteMode(View view) { // display pop-up menu with these items: AND, COPY, OR, XOR PopupMenu popup = new PopupMenu(this, view); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.pastemode_menu, popup.getMenu()); popup.show();/*from ww w . j av a 2 s . co m*/ }
From source file:com.tlongdev.bktf.ui.fragment.FavoritesFragment.java
@Override public void onMoreClicked(View view, final Item item) { PopupMenu menu = new PopupMenu(getActivity(), view); menu.getMenuInflater().inflate(R.menu.popup_item, menu.getMenu()); menu.getMenu().findItem(R.id.favorite).setTitle("Remove from favorites"); menu.getMenu().findItem(R.id.calculator).setEnabled(!Utility.isInCalculator(getActivity(), item)); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*from ww w. j av a 2 s . c o m*/ public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.history: Intent i = new Intent(getActivity(), PriceHistoryActivity.class); i.putExtra(PriceHistoryActivity.EXTRA_ITEM, item); startActivity(i); break; case R.id.favorite: Utility.removeFromFavorites(getActivity(), item); mAdapter.removeItem(item); break; case R.id.calculator: Utility.addToCalculator(getActivity(), item); menuItem.setEnabled(false); break; case R.id.backpack_tf: CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(), Uri.parse(item.getBackpackTfUrl()), new WebViewFallback()); break; case R.id.wiki: CustomTabActivityHelper.openCustomTab(getActivity(), new CustomTabsIntent.Builder().build(), Uri.parse(item.getTf2WikiUrl()), new WebViewFallback()); break; } return true; } }); menu.show(); }
From source file:de.aw.monma.wertpapier.FragmentWertpapierBuchungenListe.java
@Override public void onClick(View v) { switch (v.getId()) { case R.id.awlib_defaultFAB: PopupMenu popUpMenu = new PopupMenu(getActivity(), v); Menu menu = popUpMenu.getMenu(); // Aufbau des zugehoerigen Submenues for (WPUmsatzArt umsatzArt : WPUmsatzArt.values()) { switch (umsatzArt) { case Kauf: case OthrInc: case WP_Einlage: case Ausgabe: Intent intent = new Intent(getActivity(), ActivityWPUmsatz.class); intent.putExtra(ACTION, (Parcelable) Action.DoWertpapierUmsatz); intent.putExtra(ACCOUNTID, mAccountID); intent.putExtra(WPUMSATZART, umsatzArt); MenuItem item = menu.add(Menu.NONE, umsatzArt.getTextResID(), Menu.NONE, umsatzArt.getBeschreibungID()); item.setIntent(intent);//from w w w.j ava 2s . c o m } } popUpMenu.show(); break; default: } }
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/* w w w . j av a 2s. c o m*/ 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:org.hawkular.client.android.fragment.TriggersFragment.java
private void showTriggerMenu(final View triggerView, final int triggerPosition) { PopupMenu triggerMenu = new PopupMenu(getActivity(), triggerView); triggerMenu.getMenuInflater().inflate(R.menu.popup_add, triggerMenu.getMenu()); triggerMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//from ww w . jav a2s .com public boolean onMenuItemClick(MenuItem menuItem) { Trigger trigger = getTriggersAdapter().getItem(triggerPosition); switch (menuItem.getItemId()) { case R.id.menu_add: Context context = getActivity(); SQLStore<Trigger> store = openStore(context); store.openSync(); store.save(trigger); onRefresh(); return true; default: return false; } } }); triggerMenu.show(); }
From source file:com.aman.stockcalculator.Calculator.java
private PopupMenu constructPopupMenu() { final PopupMenu popupMenu = new PopupMenu(this, mOverflowMenuButton); final Menu menu = popupMenu.getMenu(); popupMenu.inflate(R.menu.menu);/*from ww w. j a v a 2 s . co m*/ popupMenu.setOnMenuItemClickListener(this); onPrepareOptionsMenu(menu); return popupMenu; }