本文整理匯總了Java中android.view.Menu.addSubMenu方法的典型用法代碼示例。如果您正苦於以下問題:Java Menu.addSubMenu方法的具體用法?Java Menu.addSubMenu怎麽用?Java Menu.addSubMenu使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.Menu
的用法示例。
在下文中一共展示了Menu.addSubMenu方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateOptionsMenu
import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuItem menuItem = menu.add(0, MENU_ENTITIES, 0, R.string.entities);
menuItem.setIcon(R.drawable.menu_entities);
menuItem = menu.add(0, MENU_SCHEDULED_TRANSACTIONS, 0, R.string.scheduled_transactions);
menuItem.setIcon(R.drawable.ic_menu_today);
menuItem = menu.add(0, MENU_MASS_OP, 0, R.string.mass_operations);
menuItem.setIcon(R.drawable.ic_menu_agenda);
menuItem = menu.add(0, MENU_CLOUD_SYNC, 0, R.string.flowzr_sync);
menuItem.setIcon(R.drawable.ic_menu_refresh);
menuItem = menu.add(0, MENU_BACKUP, 0, R.string.backup_database);
menuItem.setIcon(R.drawable.ic_menu_upload);
menuItem.setIcon(android.R.drawable.ic_menu_preferences);
menu.addSubMenu(0, MENU_PLANNER, 0, R.string.planner);
menu.addSubMenu(0, MENU_PREFERENCES, 0, R.string.preferences);
menu.addSubMenu(0, MENU_RESTORE, 0, R.string.restore_database);
menu.addSubMenu(0, MENU_BACKUP_RESTORE_ONLINE, 0, R.string.backup_restore_database_online);
menu.addSubMenu(0, MENU_IMPORT_EXPORT, 0, R.string.import_export);
menu.addSubMenu(0, MENU_BACKUP_TO, 0, R.string.backup_database_to);
menu.addSubMenu(0, MENU_INTEGRITY_FIX, 0, R.string.integrity_fix);
menu.addSubMenu(0, MENU_DONATE, 0, R.string.donate);
menu.addSubMenu(0, MENU_ABOUT, 0, R.string.about);
return true;
}
示例2: appendFragments
import android.view.Menu; //導入方法依賴的package包/類
private void appendFragments(boolean setShortcuts) {
sActualFragments.clear();
Menu menu = mNavigationView.getMenu();
menu.clear();
SubMenu lastSubMenu = null;
for (NavigationFragment navigationFragment : sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
Drawable drawable = ContextCompat.getDrawable(this,
Utils.DONATED
&& Prefs.getBoolean("section_icons", true, this)
&& navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
R.drawable.ic_blank);
if (fragment == null) {
lastSubMenu = menu.addSubMenu(id);
sActualFragments.put(id, null);
} else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
true, this)) {
MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
lastSubMenu.add(0, id, 0, id);
menuItem.setIcon(drawable);
menuItem.setCheckable(true);
if (mSelection != 0) {
mNavigationView.setCheckedItem(mSelection);
}
sActualFragments.put(id, fragment);
}
}
if (setShortcuts) {
setShortcuts();
}
}
示例3: appendFragments
import android.view.Menu; //導入方法依賴的package包/類
private void appendFragments(boolean setShortcuts) {
sActualFragments.clear();
Menu menu = mNavigationView.getMenu();
menu.clear();
SubMenu lastSubMenu = null;
for (NavigationFragment navigationFragment : sFragments) {
Fragment fragment = navigationFragment.mFragment;
int id = navigationFragment.mId;
Drawable drawable = ContextCompat.getDrawable(this,
Utils.DONATED
&& Prefs.getBoolean("section_icons", false, this)
&& navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
R.drawable.ic_blank);
if (fragment == null) {
lastSubMenu = menu.addSubMenu(id);
sActualFragments.put(id, null);
} else if (Prefs.getBoolean(fragment.getClass().getSimpleName() + "_enabled",
true, this)) {
MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
lastSubMenu.add(0, id, 0, id);
menuItem.setIcon(drawable);
menuItem.setCheckable(true);
if (mSelection != 0) {
mNavigationView.setCheckedItem(mSelection);
}
sActualFragments.put(id, fragment);
}
}
if (setShortcuts) {
setShortcuts();
}
}
示例4: onCreateOptionsMenu
import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.user_profile, menu);
if (mUser != null && TextUtils.equals(mAccount.screenName(), mUser.getScreenName())) {
menu.findItem(R.id.menu_direct).setVisible(false);
menu.findItem(R.id.menu_reply).setVisible(false);
menu.findItem(R.id.menu_spam).setVisible(false);
menu.findItem(R.id.menu_block).setVisible(false);
menu.findItem(R.id.menu_follow).setVisible(false);
}
List<UserList> userLists = mUserListsModel.lists().toBlocking().first();
if (mUser != null && !userLists.isEmpty()) {
final SubMenu listSubMenu = menu.addSubMenu(R.string.add_to_list);
for (UserList userList : userLists) {
listSubMenu.add(0, (int) userList.listId(), Menu.NONE, userList.name());
}
}
if (mRelationship != null) {
boolean isFollowing = mRelationship.isSourceFollowingTarget();
boolean isBlocking = mRelationship.isSourceBlockingTarget();
menu.findItem(R.id.menu_follow)
.setIcon(isFollowing ? R.drawable.ic_account_remove : R.drawable.ic_person_add)
.setTitle(isFollowing ? R.string.unfollow : R.string.follow);
menu.findItem(R.id.menu_block)
.setTitle(isBlocking ? R.string.unblock : R.string.block);
}
return super.onCreateOptionsMenu(menu);
}
示例5: onCreateOptionsMenu
import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.starred, menu);
MenuInflater inflater2 = getMenuInflater();
inflater2.inflate(R.menu.share, menu);
Intent i = new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL);
if (getPackageManager().resolveActivity(i, 0) != null) {
MenuInflater inflater1 = getMenuInflater();
inflater1.inflate(R.menu.equalizer, menu);
}
MenuInflater inflater3 = getMenuInflater();
inflater3.inflate(R.menu.settings, menu);
if (!MusicUtils.getBooleanPref(this, "radiomode", false)) {
SubMenu menu1 = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
if (!MusicUtils.getBooleanPref(this, "radiomode", false)) {
MusicUtils.makePlaylistMenuOnline(this, menu1);
}
menu.add(1, SEARCH_LYRICS, 0, R.string.search_lyrics_menu_short);
}
menu.add(1, ABOUT + 2, 0, R.string.carmode_menu_short);
if (mSettings.getBoolean(PreferencesActivity.POPUP_ON, false))
menu.add(1, ABOUT + 1, 0, R.string.go_popup);
menu.add(1, ABOUT, 0, R.string.about_menu_short);
menu.add(1, EXIT, 0, R.string.exit_menu);
return true;
}
示例6: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
YoutubeFragment ytf = new YoutubeFragment();
MusicUtils.execute(false, ytf.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例7: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
FreeMusicArchiveOrgFragment fmaf = new FreeMusicArchiveOrgFragment();
MusicUtils.execute(false, fmaf.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例8: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_soundcloud_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
SoundcloudFragment scf = new SoundcloudFragment();
MusicUtils.execute(false, scf.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例9: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
OnlineSearchAllFragment osf = new OnlineSearchAllFragment();
MusicUtils.execute(false, osf.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例10: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
BandcampFragment bcf = new BandcampFragment();
MusicUtils.execute(false, bcf.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例11: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
menu.add(0, PLAY_SELECTION, 0, R.string.play_selection);
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(activity, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case PLAY_SELECTION:
if (isNetworkAvailable(activity)) {
ArchiveOrgFragment aof = new ArchiveOrgFragment();
MusicUtils.execute(false, aof.new clickerTask(position,
false), true);
}
break;
case QUEUE:
MusicUtils.addToExistingPlaylist(activity, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(activity, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(activity, playlist, mLib
.getVideos().get(mSelectedPosition), 0);
return true;
case SEARCH:
context.startActivity(
new Intent(Intent.ACTION_VIEW, Uri
.parse(mLib.getVideos().get(position)
.getLink())));
break;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}
示例12: showUpPopup
import android.view.Menu; //導入方法依賴的package包/類
public static void showUpPopup(final Activity context, View v,
final int position) {
PopupMenu popup = new PopupMenu(context, v);
Menu menu = popup.getMenu();
/** Adding menu items to the popumenu */
mSelectedPosition = position;
SubMenu sub = menu.addSubMenu(0, ADD_TO_PLAYLIST, 0,
R.string.add_to_playlist);
MusicUtils.makePlaylistMenuOnline(context, sub);
menu.add(0, SEARCH, 0, R.string.search_internet_menu_short);
menu.add(0, DELETE_ITEM, 0, R.string.remove_from_playlist);
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case QUEUE:
MusicUtils.addToExistingPlaylist(context, "queue", mLib
.getVideos().get(mSelectedPosition));
return true;
case NEW_PLAYLIST:
Bundle data = new Bundle();
data.putSerializable("TRACK",
mLib.getVideos().get(mSelectedPosition));
Intent intent = new Intent(context, CreatePlaylist.class);
intent.putExtra("online", true);
intent.putExtra("track", data);
context.startActivity(intent);
return true;
case PLAYLIST_SELECTED:
String playlist = item.getIntent().getStringExtra("name");
MusicUtils.addToExistingPlaylist(context, playlist, mLib
.getVideos().get(mSelectedPosition));
return true;
case DELETE_ITEM:
MusicUtils.removeFromPlaylist(mPlaylist, position, context);
populateListWithVideos(activity, activity);
return true;
}
return true;
}
});
/** Showing the popup menu */
popup.show();
}