List of usage examples for android.widget PopupMenu getMenuInflater
public MenuInflater getMenuInflater()
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;//from w w w . ja v a2s . com } 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:org.xbmc.kore.ui.sections.audio.SongsListFragment.java
private void showPopupMenu(View v) { final ViewHolder viewHolder = (ViewHolder) v.getTag(); final PlaylistType.Item playListItem = new PlaylistType.Item(); playListItem.songid = viewHolder.songInfo.songId; final PopupMenu popupMenu = new PopupMenu(getActivity(), v); popupMenu.getMenuInflater().inflate(R.menu.song_item, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override//w w w.ja v a2s . c o m public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.action_play_song: MediaPlayerUtils.play(SongsListFragment.this, playListItem); return true; case R.id.action_add_to_playlist: MediaPlayerUtils.queue(SongsListFragment.this, playListItem, PlaylistType.GetPlaylistsReturnType.AUDIO); return true; case R.id.download: ArrayList<FileDownloadHelper.SongInfo> songInfoList = new ArrayList<>(); songInfoList.add(viewHolder.songInfo); UIUtils.downloadSongs(getActivity(), songInfoList, HostManager.getInstance(getActivity()).getHostInfo(), callbackHandler); } return false; } }); popupMenu.show(); }
From source file:org.hawkular.client.android.fragment.AlertDetailFragment.java
private void showAlertMenu(final View view) { PopupMenu alertMenu = new PopupMenu(getActivity(), view); alertMenu.getMenuInflater().inflate(R.menu.popup_alerts, alertMenu.getMenu()); alertMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override/*from ww w . j a va2 s . c o m*/ public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.menu_resolve: BackendClient.of(AlertDetailFragment.this).resolveAlert(alert, new AlertActionCallback(R.string.alert_state_res)); return true; case R.id.menu_acknowledge: BackendClient.of(AlertDetailFragment.this).acknowledgeAlert(alert, new AlertActionCallback(R.string.alert_state_ack)); return true; default: return false; } } }); alertMenu.show(); }
From source file:sharedcode.turboeditor.activity.SelectFileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { ThemeUtils.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_select_file); Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar);//w ww .ja v a 2 s .c o m getSupportActionBar().setDisplayHomeAsUpEnabled(true); final Actions action = (Actions) getIntent().getExtras().getSerializable("action"); wantAFile = action == Actions.SelectFile; listView = (ListView) findViewById(android.R.id.list); listView.setOnItemClickListener(this); listView.setTextFilterEnabled(true); FloatingActionButton mFab = (FloatingActionButton) findViewById(R.id.fabbutton); mFab.setColor(getResources().getColor(R.color.fab_light)); mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add)); mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu popup = new PopupMenu(SelectFileActivity.this, v); popup.getMenuInflater().inflate(R.menu.popup_new_file, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.im_new_file) { EditTextDialog.newInstance(EditTextDialog.Actions.NewFile) .show(getFragmentManager().beginTransaction(), "dialog"); return true; } else if (i == R.id.im_new_folder) { EditTextDialog.newInstance(EditTextDialog.Actions.NewFolder) .show(getFragmentManager().beginTransaction(), "dialog"); return true; } else { return false; } } }); popup.show(); } }); mFab.listenTo(listView); String lastNavigatedPath = PreferenceHelper.getWorkingFolder(this); File file = new File(lastNavigatedPath); if (!file.exists()) { PreferenceHelper.setWorkingFolder(this, PreferenceHelper.SD_CARD_ROOT); file = new File(PreferenceHelper.SD_CARD_ROOT); } new UpdateList().execute(file.getAbsolutePath()); }
From source file:org.videolan.vlc.gui.video.VideoGridFragment.java
@TargetApi(11) public void onContextPopupMenu(View anchor, final int position) { if (!Util.isHoneycombOrLater()) { // Call the "classic" context menu anchor.performLongClick();/*from ww w .j a v a 2s . c o m*/ return; } PopupMenu popupMenu = new PopupMenu(getActivity(), anchor); popupMenu.getMenuInflater().inflate(R.menu.video_list, popupMenu.getMenu()); popupMenu.setOnMenuItemClickListener(new OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { return handleContextItemSelected(item, position); } }); popupMenu.show(); }
From source file:org.messic.android.smartphone.activities.main.MainActivity.java
private void openSettings() { View anchor = findViewById(R.id.action_settings); // Creating the instance of PopupMenu PopupMenu popup = new PopupMenu(this, anchor); // Inflating the Popup using xml file popup.getMenuInflater().inflate(R.menu.activity_main_menu, popup.getMenu()); // registering popup with OnMenuItemClickListener popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.menu_base_item_removedatabase: emptyDatabaseAction();/*from w ww . j a v a2 s . c om*/ break; case R.id.menu_base_item_logout: presenter.logout(); Intent intent = new Intent(MainActivity.this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); // call this to finish the current activity break; case R.id.menu_base_item_clearplaylist: presenter.clearQueue(); break; case R.id.menu_base_item_playrandom: presenter.addRandomSongsToPlaylist(); break; case R.id.menu_base_item_showlicense: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.gnu.org/licenses/gpl-3.0-standalone.html")); startActivity(browserIntent); break; } return true; } }); popup.show();// showing popup menu }
From source file:de.aw.monma.mainscreen.ActivityMainScreen.java
@Override public boolean onRecyclerItemLongClick(RecyclerView recyclerView, View view, int position, long id, int viewHolderLayoutID) { switch (viewHolderLayoutID) { case R.layout.reportlist_item: PopupMenu popUpMenu = new PopupMenu(this, view); Menu menu = popUpMenu.getMenu(); popUpMenu.getMenuInflater().inflate(R.menu.context_fragment_report_selection, menu); for (int i = 0; i < menu.size(); i++) { Intent intent = new Intent(); intent.putExtra(ID, id);//from ww w . j av a2 s . c o m menu.getItem(i).setIntent(intent); } popUpMenu.setOnMenuItemClickListener(this); popUpMenu.show(); return true; case R.layout.finanzuebersicht_item: DialogFragmentKontoEdit d = DialogFragmentKontoEdit.newInstance(new Account((int) id)); d.show(getSupportFragmentManager(), null); return true; case R.layout.hbcipassport_item: final long mID = id; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.HBCIZugangDelete); builder.setMessage(R.string.HBCIZugangDeleteMsg); builder.setPositiveButton(getString(R.string.awlib_btnAccept), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { MonMaPassport passport = new MonMaPassport(mID); passport.delete(DBHelper.getInstance()); } catch (GeschaeftsObjekt.LineNotFoundException e) { //TODO Execption bearbeiten e.printStackTrace(); } } }); builder.setNegativeButton(getString(R.string.awlib_btnCancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.create().show(); return true; default: return false; } }
From source file:sharedcode.wyeditor.ui.activity.SelectFileActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { currentFolder = PreferenceHelper.defaultFolder(this); ThemeUtils.setTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_select_file); Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar); setSupportActionBar(toolbar);/*ww w . ja v a 2 s . c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); //final Actions action = (Actions) getIntent().getExtras().getSerializable("action"); wantAFile = true; //action == Actions.SelectFile; listView = (ListView) findViewById(android.R.id.list); listView.setOnItemClickListener(this); listView.setTextFilterEnabled(true); FloatingActionButton mFab = (FloatingActionButton) findViewById(R.id.fabbutton); mFab.setColor(getResources().getColor(R.color.fab_light)); mFab.setDrawable(getResources().getDrawable(R.drawable.ic_fab_add)); mFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PopupMenu popup = new PopupMenu(SelectFileActivity.this, v); popup.getMenuInflater().inflate(R.menu.popup_new_file, popup.getMenu()); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { int i = item.getItemId(); if (i == R.id.im_new_file) { EditTextDialog.newInstance(EditTextDialog.Actions.NewFile) .show(getFragmentManager().beginTransaction(), "dialog"); return true; } else if (i == R.id.im_new_folder) { EditTextDialog.newInstance(EditTextDialog.Actions.NewFolder) .show(getFragmentManager().beginTransaction(), "dialog"); return true; } else { return false; } } }); popup.show(); } }); mFab.listenTo(listView); String lastNavigatedPath = PreferenceHelper.getWorkingFolder(this); File file = new File(lastNavigatedPath); if (!file.exists()) { PreferenceHelper.setWorkingFolder(this, PreferenceHelper.defaultFolder(this)); file = new File(PreferenceHelper.defaultFolder(this)); } new UpdateList().execute(file.getAbsolutePath()); }
From source file:de.enlightened.peris.ForumSettingsFragment.java
private void setupHomeButton(final SharedPreferences appPreferences) { //Home Page button final LinearLayout forumSettingHome = (LinearLayout) getActivity().findViewById(R.id.forum_setting_home); forumSettingHome.setOnClickListener(new View.OnClickListener() { @Override// w w w . java 2 s . c o m @SuppressWarnings("checkstyle:requirethis") public void onClick(final View v) { final PopupMenu popup = new PopupMenu(getActivity(), v); final MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.home_page_selection, popup.getMenu()); popup.setOnMenuItemClickListener(forumHomeSelectedListener); popup.show(); } }); //Home Page Display Text final String currentServerId = this.application.getSession().getServer().serverId; final String keyName = currentServerId + "_home_page"; String valueName = getString(R.string.subforum_id); String displayName = "Forum Index"; valueName = appPreferences.getString(keyName, getString(R.string.subforum_id)); if (valueName.contentEquals(getString(R.string.subforum_id))) { displayName = "Forum Index"; } if (valueName.contentEquals("forum_favs")) { displayName = "Favorites"; } if (valueName.contentEquals("timeline")) { displayName = "Timeline"; } if (valueName.contentEquals("participated")) { displayName = "Participated Topics"; } if (valueName.contentEquals("favs")) { displayName = "Subscribed Topics"; } if (valueName.contentEquals("unread")) { displayName = "Unread Topics"; } final TextView forumSettingHomeCurrent = (TextView) this.getActivity() .findViewById(R.id.forum_setting_home_current); forumSettingHomeCurrent.setText(displayName); }
From source file:net.vivekiyer.GAL.CorporateContactRecordFragment.java
@TargetApi(11) @Override//from w ww . j a v a 2s.c om public void onClick(View v) { switch (v.getId()) { case R.id.contact_actions: if (Utility.isPreHoneycomb()) { showContactQuickActions(v); return; } else { PopupMenu popup = new PopupMenu(getActivity(), v); popup.setOnMenuItemClickListener(HoneycombListeners.getPopupMenuListener(this)); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.contact_actions_menu, popup.getMenu()); popup.show(); } break; case R.id.save_contact: this.contactWriter.saveContact(getView().getContext()); default: break; } }