當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextMenu.setGroupCheckable方法代碼示例

本文整理匯總了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);
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:26,代碼來源:EqualizerActivity.java

示例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));
	}
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:47,代碼來源:SelectArtistActivity.java


注:本文中的android.view.ContextMenu.setGroupCheckable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。