本文整理匯總了Java中android.view.ContextMenu.setGroupCheckable方法的典型用法代碼示例。如果您正苦於以下問題:Java ContextMenu.setGroupCheckable方法的具體用法?Java ContextMenu.setGroupCheckable怎麽用?Java ContextMenu.setGroupCheckable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.view.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.setGroupCheckable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateContextMenu
import android.view.ContextMenu; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, view, menuInfo);
short currentPreset;
try
{
currentPreset = equalizer.getCurrentPreset();
}
catch (Exception x)
{
currentPreset = -1;
}
for (short preset = 0; preset < equalizer.getNumberOfPresets(); preset++)
{
MenuItem menuItem = menu.add(MENU_GROUP_PRESET, preset, preset, equalizer.getPresetName(preset));
if (preset == currentPreset)
{
menuItem.setChecked(true);
}
}
menu.setGroupCheckable(MENU_GROUP_PRESET, true, true);
}
示例2: onCreateContextMenu
import android.view.ContextMenu; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, view, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (artistListView.getItemAtPosition(info.position) instanceof Artist)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.select_artist_context, menu);
}
else if (info.position == 1)
{
String musicFolderId = Util.getSelectedMusicFolderId(this);
MenuItem menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, -1, 0, R.string.select_artist_all_folders);
if (musicFolderId == null)
{
menuItem.setChecked(true);
}
if (musicFolders != null)
{
for (int i = 0; i < musicFolders.size(); i++)
{
MusicFolder musicFolder = musicFolders.get(i);
menuItem = menu.add(MENU_GROUP_MUSIC_FOLDER, i, i + 1, musicFolder.getName());
if (musicFolder.getId().equals(musicFolderId))
{
menuItem.setChecked(true);
}
}
}
menu.setGroupCheckable(MENU_GROUP_MUSIC_FOLDER, true, true);
}
MenuItem downloadMenuItem = menu.findItem(R.id.artist_menu_download);
if (downloadMenuItem != null)
{
downloadMenuItem.setVisible(!Util.isOffline(this));
}
}