本文整理汇总了Java中android.view.SubMenu类的典型用法代码示例。如果您正苦于以下问题:Java SubMenu类的具体用法?Java SubMenu怎么用?Java SubMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubMenu类属于android.view包,在下文中一共展示了SubMenu类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyTypefaces
import android.view.SubMenu; //导入依赖的package包/类
private void applyTypefaces() {
Menu m = navigationView.getMenu();
for (int i = 0; i < m.size(); i++) {
MenuItem item = m.getItem(i);
//for applying a font to subMenu...
SubMenu subMenu = item.getSubMenu();
if (subMenu != null && subMenu.size() > 0) {
for (int j = 0; j < subMenu.size(); j++) {
MenuItem subMenuItem = subMenu.getItem(j);
applyTypeface(subMenuItem);
}
}
//the method we have create in activity
applyTypeface(item);
}
}
示例2: populateProjectsMenu
import android.view.SubMenu; //导入依赖的package包/类
private void populateProjectsMenu() {
if (mProjectList == null) {
if (BuildConfig.DEBUG) Log.d("Kandroid", "Tried to populate drawer, but mDashboard was null");
return;
}
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.getBaseContext());
List<KanboardProject> projList = mProjectList;
if (preferences.getBoolean("projects_sort_alphabetic", false))
Collections.sort(projList);
NavigationView nav = (NavigationView) findViewById(R.id.nav_view);
SubMenu projMenu = nav.getMenu().findItem(R.id.projects).getSubMenu();
projMenu.clear();
for (KanboardProject item: projList)
projMenu.add(Menu.NONE, item.getId(), Menu.NONE, item.getName())
.setIcon(R.drawable.project);
}
示例3: selectMenuItem
import android.view.SubMenu; //导入依赖的package包/类
public static void selectMenuItem(@NonNull Menu menu, @IdRes int itemId, boolean findSub) {
boolean find = false;
for (int i = 0; i < menu.size(); i++) {
if (!findSub) {
menu.getItem(i).setChecked(menu.getItem(i).getItemId() == itemId);
} else {
if (menu.getItem(i).getItemId() == itemId) {
find = true;
}
}
}
if (!findSub) {
return;
} else if (find) {
selectMenuItem(menu, itemId, false);
} else {
for (int i = 0; i < menu.size(); i++) {
SubMenu subMenu = menu.getItem(i).getSubMenu();
if(subMenu != null)
selectMenuItem(subMenu, itemId, true);
}
}
}
示例4: getSubMenuWrapper
import android.view.SubMenu; //导入依赖的package包/类
final SubMenu getSubMenuWrapper(SubMenu subMenu) {
if (!(subMenu instanceof SupportSubMenu)) {
return subMenu;
}
SupportSubMenu supportSubMenu = (SupportSubMenu) subMenu;
if (this.mSubMenus == null) {
this.mSubMenus = new ArrayMap();
}
SubMenu wrappedMenu = (SubMenu) this.mSubMenus.get(supportSubMenu);
if (wrappedMenu != null) {
return wrappedMenu;
}
wrappedMenu = MenuWrapperFactory.wrapSupportSubMenu(this.mContext, supportSubMenu);
this.mSubMenus.put(supportSubMenu, wrappedMenu);
return wrappedMenu;
}
示例5: onPrepareSubMenu
import android.view.SubMenu; //导入依赖的package包/类
public void onPrepareSubMenu(SubMenu subMenu) {
int i;
subMenu.clear();
ActivityChooserModel dataModel = ActivityChooserModel.get(this.mContext, this.mShareHistoryFileName);
PackageManager packageManager = this.mContext.getPackageManager();
int expandedActivityCount = dataModel.getActivityCount();
int collapsedActivityCount = Math.min(expandedActivityCount, this.mMaxShownActivityCount);
for (i = 0; i < collapsedActivityCount; i++) {
ResolveInfo activity = dataModel.getActivity(i);
subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(this.mOnMenuItemClickListener);
}
if (collapsedActivityCount < expandedActivityCount) {
SubMenu expandedSubMenu = subMenu.addSubMenu(0, collapsedActivityCount, collapsedActivityCount, this.mContext.getString(R.string.abc_activity_chooser_view_see_all));
for (i = 0; i < expandedActivityCount; i++) {
activity = dataModel.getActivity(i);
expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(this.mOnMenuItemClickListener);
}
}
}
示例6: setUpSortOrderMenu
import android.view.SubMenu; //导入依赖的package包/类
private void setUpSortOrderMenu(SubMenu subMenu) {
subMenu.removeItem(R.id.action_sort_order_title_desc);
subMenu.removeItem(R.id.action_sort_order_title);
subMenu.removeItem(R.id.action_sort_order_date);
subMenu.removeItem(R.id.action_sort_order_duration);
subMenu.removeItem(R.id.action_sort_order_year);
subMenu.removeItem(R.id.action_sort_order_artist_desc);
switch (getSavedSortOrder()) {
case AlbumSortOrder.ALBUM_A_Z:
subMenu.findItem(R.id.action_sort_order_album).setChecked(true);
break;
case AlbumSortOrder.ALBUM_Z_A:
subMenu.findItem(R.id.action_sort_order_album_desc).setChecked(true);
break;
case AlbumSortOrder.ALBUM_ARTIST:
subMenu.findItem(R.id.action_sort_order_artist).setChecked(true);
break;
}
}
示例7: setUpSortOrderMenu
import android.view.SubMenu; //导入依赖的package包/类
private void setUpSortOrderMenu(SubMenu subMenu) {
subMenu.removeItem(R.id.action_sort_order_title_desc);
subMenu.removeItem(R.id.action_sort_order_title);
subMenu.removeItem(R.id.action_sort_order_date);
subMenu.removeItem(R.id.action_sort_order_duration);
subMenu.removeItem(R.id.action_sort_order_year);
subMenu.removeItem(R.id.action_sort_order_album);
subMenu.removeItem(R.id.action_sort_order_album_desc);
switch (getSavedSortOrder()) {
case ArtistSortOrder.ARTIST_A_Z:
subMenu.findItem(R.id.action_sort_order_artist).setChecked(true);
break;
case ArtistSortOrder.ARTIST_Z_A:
subMenu.findItem(R.id.action_sort_order_artist_desc).setChecked(true);
break;
}
}
示例8: setUpSortOrderMenu
import android.view.SubMenu; //导入依赖的package包/类
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) {
switch (getSavedSortOrder()) {
case ArtistSongSortOrder.SONG_A_Z:
sortOrder.findItem(R.id.action_sort_order_title).setChecked(true);
break;
case ArtistSongSortOrder.SONG_Z_A:
sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true);
break;
case ArtistSongSortOrder.SONG_ALBUM:
sortOrder.findItem(R.id.action_sort_order_album).setChecked(true);
break;
case ArtistSongSortOrder.SONG_YEAR:
sortOrder.findItem(R.id.action_sort_order_year).setChecked(true);
break;
case ArtistSongSortOrder.SONG_DURATION:
sortOrder.findItem(R.id.action_sort_order_artist_song_duration).setChecked(true);
break;
case ArtistSongSortOrder.SONG_DATE:
sortOrder.findItem(R.id.action_sort_order_date).setChecked(true);
break;
}
}
示例9: setUpSortOrderMenu
import android.view.SubMenu; //导入依赖的package包/类
private void setUpSortOrderMenu(@NonNull SubMenu sortOrder) {
switch (getSavedSortOrder()) {
case AlbumSongSortOrder.SONG_A_Z:
sortOrder.findItem(R.id.action_sort_order_title).setChecked(true);
break;
case AlbumSongSortOrder.SONG_Z_A:
sortOrder.findItem(R.id.action_sort_order_title_desc).setChecked(true);
break;
case AlbumSongSortOrder.SONG_TRACK_LIST:
sortOrder.findItem(R.id.action_sort_order_track_list).setChecked(true);
break;
case AlbumSongSortOrder.SONG_DURATION:
sortOrder.findItem(R.id.action_sort_order_artist_song_duration).setChecked(true);
break;
}
}
示例10: onCreateOptionsMenu
import android.view.SubMenu; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "Local").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
SubMenu subDebug = menu.addSubMenu(100, 100, 100, "Dev tools...");
subDebug.add(2, 2, 2, "TEST!");
subDebug.add(8, 8, 8, "Override inet address");
subDebug.add(9, 9, 9, "Save logs");
SubMenu subDomain = menu.addSubMenu(101, 101, 101, "Domain...");
subDomain.add(3, 3, 3, "Save our world now");
SubMenu subDb = menu.addSubMenu(102, 102, 102, "Database...");
subDb.add(5, 5, 5, "Import file to db");
subDb.add(6, 6, 6, "Export from db");
menu.add(7, 7, 7, "Kill myself with pleasure");
return true;
}
示例11: onCreateOptionsMenu
import android.view.SubMenu; //导入依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem filterItem = menu.findItem(R.id.songbook_filter_category);
if (null != filterItem) {
SubMenu subMenu = filterItem.getSubMenu();
subMenu.clear();
if (null != mSongbook) {
subMenu.add(Menu.NONE, MENU_CLEAR_FILTER_ID, Menu.NONE, R.string.songbook_show_all);
List<String> categories = mSongbook.categories();
for (int i = 0; i < categories.size(); i++) {
subMenu.add(MENU_CATEGORIES_ID, MENU_CATEGORIES_ID + i, Menu.NONE, categories.get(i));
}
}
}
}
示例12: m2088a
import android.view.SubMenu; //导入依赖的package包/类
final SubMenu m2088a(SubMenu subMenu) {
if (!(subMenu instanceof C0091c)) {
return subMenu;
}
C0091c c0091c = (C0091c) subMenu;
if (this.f956d == null) {
this.f956d = new C0107a();
}
SubMenu subMenu2 = (SubMenu) this.f956d.get(c0091c);
if (subMenu2 != null) {
return subMenu2;
}
subMenu2 = ab.m2086a(this.f954a, c0091c);
this.f956d.put(c0091c, subMenu2);
return subMenu2;
}
示例13: setupNavMenu
import android.view.SubMenu; //导入依赖的package包/类
/**
* Setups the navigation drawer's menu to include the given collection of subreddits.
* The subreddit portion of this menu is rebuilt each time.
*
* @param subreddits the collection of subreddits to add to the menu
*/
private void setupNavMenu(Collection<String> subreddits) {
NavigationView mNavView = (NavigationView) findViewById(R.id.nav_view);
if (subreddits.isEmpty() || mNavView == null) return;
Menu menu = mNavView.getMenu();
menu.removeGroup(SUBREDDIT_MENU_GRP);
SubMenu subMenu = menu.addSubMenu(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, "Subreddit");
for (String subreddit : subreddits) {
subMenu.add(SUBREDDIT_MENU_GRP, Menu.NONE, Menu.NONE, subreddit);
}
subMenu.setGroupCheckable(SUBREDDIT_MENU_GRP, true, true);
mNavView.setNavigationItemSelectedListener(item -> {
selectNavItem(item);
return true;
});
}
示例14: populateIndex
import android.view.SubMenu; //导入依赖的package包/类
private Index populateIndex(NavigationView navigationView) {
Index specIndex = mSpecReader.getIndex(getAssets());
Menu menu = navigationView.getMenu();
@IdRes final int STARTING_MENU_ITEM_ID = 1;
@IdRes int menuItemId = STARTING_MENU_ITEM_ID;
for (IndexSection section : specIndex.sections) {
String sectionTitle = section.title;
SubMenu submenu = menu.addSubMenu(sectionTitle);
for (IndexSubsection subsection : section.sections) {
String subsectionTitle = subsection.title;
submenu
.add(Menu.NONE, menuItemId, Menu.NONE, subsectionTitle)
.setCheckable(true);
mMenuItemIdToIndexSubsection.put(menuItemId, subsection);
mIndexSubsectionToMenuItemId.put(subsection, menuItemId);
mRelativeHrefToIndexSubsection.put(specHrefToRelativeHref(subsection.href), subsection);
++menuItemId;
}
}
navigationView.setCheckedItem(STARTING_MENU_ITEM_ID);
return specIndex;
}
示例15: onCreateOptionsMenu
import android.view.SubMenu; //导入依赖的package包/类
@Override public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_ignore_setting, menu);
SubMenu subMenu = menu.addSubMenu(GROUP_ID, BASE_ID, 0, "排序");
subMenu.setIcon(R.drawable.ic_sort_white_24dp);
subMenu.add(GROUP_ID + 1, BASE_ID + 1, 0, "应用名");
subMenu.add(GROUP_ID + 1, BASE_ID + 2, 1, "选中");
subMenu.add(GROUP_ID + 2, BASE_ID + 3, 2, "降序")
.setCheckable(true)
.setChecked(true);
subMenu.setGroupCheckable(GROUP_ID + 1, true, true);
mMenuItem = menu.findItem(R.id.allcheck);
ActionItemBadge.update(this, mMenuItem, FontAwesome.Icon.faw_check,
ActionItemBadge.BadgeStyles.DARK_GREY, 0);
return true;
}