Java Code Examples for android.support.v7.widget.PopupMenu#getMenuInflater()
The following examples show how to use
android.support.v7.widget.PopupMenu#getMenuInflater() .
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: WalkingModesAdapter.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
public void showPopup(View v, Context c) { PopupMenu popup = new PopupMenu(c, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_card_walking_mode, popup.getMenu()); popup.getMenu().findItem(R.id.menu_set_active).setChecked(isActive); popup.setOnMenuItemClickListener(this); popup.show(); }
Example 2
Source File: MotivationAlertTextsAdapter.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
public void showPopup(View v, Context c) { PopupMenu popup = new PopupMenu(c, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_card_motivation_text, popup.getMenu()); popup.setOnMenuItemClickListener(this); popup.show(); }
Example 3
Source File: ReportAdapter.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
public void showPopup(View v, Context c) { PopupMenu popup = new PopupMenu(c, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_card_activity_summary, popup.getMenu()); popup.setOnMenuItemClickListener(this); if (mItemClickListener != null) { mItemClickListener.setActivityChartDataTypeChecked(popup.getMenu()); } popup.show(); }
Example 4
Source File: TrainingOverviewAdapter.java From privacy-friendly-pedometer with GNU General Public License v3.0 | 5 votes |
public void showPopup(View v, Context c) { PopupMenu popup = new PopupMenu(c, v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_card_training_session, popup.getMenu()); popup.setOnMenuItemClickListener(this); popup.show(); }
Example 5
Source File: WorldMapDialog.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
protected boolean showSpeedMenu(final Context context, View view) { PopupMenu menu = new PopupMenu(context, view); MenuInflater inflater = menu.getMenuInflater(); inflater.inflate(R.menu.mapmenu_speed, menu.getMenu()); menu.setOnMenuItemClickListener(onSpeedMenuClick); updateSpeedMenu(context, menu); menu.show(); return true; }
Example 6
Source File: WorldMapDialog.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
protected boolean showContextMenu(final Context context, View view) { PopupMenu menu = new PopupMenu(context, view); MenuInflater inflater = menu.getMenuInflater(); inflater.inflate(R.menu.mapmenu, menu.getMenu()); menu.setOnMenuItemClickListener(onContextMenuClick); updateContextMenu(context, menu); SuntimesUtils.forceActionBarIcons(menu.getMenu()); menu.show(); return true; }
Example 7
Source File: AlarmClockAdapter.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
/** * showAlarmTypeMenu * @param item AlarmClockItem * @param buttonView button that triggered menu * @param itemView view associated with item */ protected void showAlarmTypeMenu(final AlarmClockItem item, final View buttonView, final View itemView) { PopupMenu menu = new PopupMenu(context, buttonView); MenuInflater inflater = menu.getMenuInflater(); inflater.inflate(R.menu.alarmtype, menu.getMenu()); menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { switch (menuItem.getItemId()) { case R.id.alarmTypeNotification: return changeAlarmType(item, AlarmClockItem.AlarmType.NOTIFICATION); case R.id.alarmTypeAlarm: default: return changeAlarmType(item, AlarmClockItem.AlarmType.ALARM); } } }); SuntimesUtils.forceActionBarIcons(menu.getMenu()); menu.show(); }
Example 8
Source File: CodePresenter.java From open-location-code with Apache License 2.0 | 5 votes |
private void openShareMenu() { PopupMenu popup = new PopupMenu(mView.getContext(), mView.getShareButton()); popup.setOnMenuItemClickListener(this); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.share_menu, popup.getMenu()); popup.show(); }
Example 9
Source File: MainActivity.java From Bluefruit_LE_Connect_Android with MIT License | 5 votes |
public void onClickFilterNameSettings(View view) { PopupMenu popup = new PopupMenu(this, view); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { boolean processed = true; switch (item.getItemId()) { case R.id.scanfilter_name_contains: mPeripheralList.setFilterNameExact(false); break; case R.id.scanfilter_name_exact: mPeripheralList.setFilterNameExact(true); break; case R.id.scanfilter_name_sensitive: mPeripheralList.setFilterNameCaseInsensitive(false); break; case R.id.scanfilter_name_insensitive: mPeripheralList.setFilterNameCaseInsensitive(true); break; default: processed = false; break; } updateFilters(); return processed; } }); MenuInflater inflater = popup.getMenuInflater(); Menu menu = popup.getMenu(); inflater.inflate(R.menu.menu_scan_filters_name, menu); final boolean isFilterNameExact = mPeripheralList.isFilterNameExact(); menu.findItem(isFilterNameExact ? R.id.scanfilter_name_exact : R.id.scanfilter_name_contains).setChecked(true); final boolean isFilterNameCaseInsensitive = mPeripheralList.isFilterNameCaseInsensitive(); menu.findItem(isFilterNameCaseInsensitive ? R.id.scanfilter_name_insensitive : R.id.scanfilter_name_sensitive).setChecked(true); popup.show(); }
Example 10
Source File: MainActivity.java From LinkedME-Android-Deep-Linking-Demo with GNU General Public License v3.0 | 4 votes |
public void showPopup(View v) { PopupMenu popup = new PopupMenu(this, v); popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { switch (item.getItemId()) { case R.id.login: if (SPHelper.getInstance(getApplicationContext()).getUserLogin()) { Toast.makeText(MainActivity.this, "已登录!", Toast.LENGTH_SHORT).show(); } else { Intent intent = new Intent(MainActivity.this, LoginActivity.class); startActivity(intent); finish(); } return true; case R.id.logout: if (SPHelper.getInstance(getApplicationContext()).getUserLogin()) { SPHelper.getInstance(getApplicationContext()).setUserLogin(false); // 此处针对跳转是否受用户登录限制的情况,在此处重置为false,防止用户点击退出后退到后台再唤起APP时跳转到详情页 if (LinkedME.getInstance() != null) { LinkedME.getInstance().setImmediate(false); } Toast.makeText(MainActivity.this, "退出成功!", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, "未登录,无需退出!", Toast.LENGTH_SHORT).show(); } return true; default: return false; } } }); MenuInflater inflater = popup.getMenuInflater(); if (SPHelper.getInstance(getApplicationContext()).getUserLogin()) { inflater.inflate(R.menu.menu_main_login, popup.getMenu()); } else { inflater.inflate(R.menu.menu_main, popup.getMenu()); } popup.show(); }
Example 11
Source File: ArtistListData.java From Pasta-for-Spotify with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.menu: PopupMenu popup = new PopupMenu(v.getContext(), v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_basic, popup.getMenu()); final MenuItem fav = popup.getMenu().findItem(R.id.action_fav); new Action<Boolean>() { @NonNull @Override public String id() { return "isTrackFav"; } @Nullable @Override protected Boolean run() throws InterruptedException { return pasta.isFavorite(listData); } @Override protected void done(@Nullable Boolean result) { if (result == null) return; if (result) { fav.setTitle(R.string.unfav); } else { fav.setTitle(R.string.fav); } } }.execute(); popup.setOnMenuItemClickListener(this); popup.show(); break; default: Bundle args = new Bundle(); args.putParcelable("artist", listData); Fragment f = new ArtistFragment(); f.setArguments(args); activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment, f).addToBackStack(null).commit(); break; } }
Example 12
Source File: PlaylistListData.java From Pasta-for-Spotify with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.menu: PopupMenu popup = new PopupMenu(v.getContext(), v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_playlist, popup.getMenu()); final MenuItem fav = popup.getMenu().findItem(R.id.action_fav); new Action<Boolean>() { @NonNull @Override public String id() { return "isPlaylistFav"; } @Nullable @Override protected Boolean run() throws InterruptedException { return pasta.isFavorite(listData); } @Override protected void done(@Nullable Boolean result) { if (result == null) return; if (result) { fav.setTitle(R.string.unfav); } else { fav.setTitle(R.string.fav); } } }.execute(); popup.setOnMenuItemClickListener(this); popup.getMenu().findItem(R.id.action_edit).setVisible(listData.editable); popup.show(); break; default: Bundle args = new Bundle(); args.putParcelable("playlist", listData); Fragment f = new PlaylistFragment(); f.setArguments(args); activity.getSupportFragmentManager().beginTransaction().replace(R.id.fragment, f).addToBackStack(null).commit(); break; } }
Example 13
Source File: TrackListData.java From Pasta-for-Spotify with Apache License 2.0 | 4 votes |
@Override public void onClick(View v) { switch (v.getId()) { case R.id.menu: PopupMenu popup = new PopupMenu(v.getContext(), v); MenuInflater inflater = popup.getMenuInflater(); inflater.inflate(R.menu.menu_track, popup.getMenu()); final MenuItem fav = popup.getMenu().findItem(R.id.action_fav); new Action<Boolean>() { @NonNull @Override public String id() { return "isTrackFav"; } @Nullable @Override protected Boolean run() throws InterruptedException { return pasta.isFavorite(listData); } @Override protected void done(@Nullable Boolean result) { if (result == null) return; if (result) { fav.setTitle(R.string.unfav); } else { fav.setTitle(R.string.fav); } } }.execute(); popup.setOnMenuItemClickListener(this); popup.show(); break; default: ArrayList<TrackListData> trackList = new ArrayList<TrackListData>(); if (listData.tracks != null) trackList.addAll(listData.tracks); else trackList.add(listData); StaticUtils.play(trackList.indexOf(listData), trackList, activity); ActivityOptionsCompat options = ActivityOptionsCompat.makeCustomAnimation(activity, R.anim.slide_up, R.anim.blank); activity.startActivity(new Intent(activity, PlayerActivity.class), options.toBundle()); break; } }