本文整理汇总了Java中android.view.ContextMenu.ContextMenuInfo类的典型用法代码示例。如果您正苦于以下问题:Java ContextMenuInfo类的具体用法?Java ContextMenuInfo怎么用?Java ContextMenuInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContextMenuInfo类属于android.view.ContextMenu包,在下文中一共展示了ContextMenuInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
/**
* Creates context menu for certain actions on a specific item.
*/
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (v instanceof ListView) {
ListView listView = (ListView) v;
Object item = listView.getAdapter().getItem(info.position);
if (item instanceof DIDLObject) {
selectedDIDLObject = (DIDLObject) item;
}
}
menu.setHeaderTitle(v.getContext().getString(
R.string.browse_context_title));
ArrayList<String> menuItems = new ArrayList<String>();
menuItems.add(v.getContext().getString(R.string.browse_context_play_all));
menuItems.add(v.getContext().getString(R.string.browse_context_play));
//menuItems.add(v.getContext().getString( R.string.browse_context_add_to_playplist));
menuItems.add(v.getContext()
.getString(R.string.browse_context_download));
for (int i = 0; i < menuItems.size(); i++) {
menu.add(Menu.NONE, i, i, menuItems.get(i));
}
}
示例2: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) menuInfo;
} catch (ClassCastException e) {
Log.e(THIS_FILE, "bad menuInfo", e);
return;
}
HashMap<String, Object> codec = (HashMap<String, Object>) mAdapter.getItem(info.position);
if (codec == null) {
// If for some reason the requested item isn't available, do nothing
return;
}
boolean isDisabled = ((Short)codec.get(CODEC_PRIORITY) == 0);
menu.add(0, MENU_ITEM_ACTIVATE, 0, isDisabled ? R.string.activate : R.string.deactivate);
}
示例3: profileFromContextMenuInfo
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
/**
* Retrieve sip account from a given context menu info pressed
* @param cmi The context menu info to retrieve infos from
* @return corresponding sip profile if everything goes well, null if not able to retrieve profile
*/
private SipProfile profileFromContextMenuInfo(ContextMenuInfo cmi) {
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) cmi;
} catch (ClassCastException e) {
Log.e(THIS_FILE, "bad menuInfo", e);
return null;
}
Cursor c = (Cursor) getListAdapter().getItem(info.position - getListView().getHeaderViewsCount());
if (c == null) {
// For some reason the requested item isn't available, do nothing
return null;
}
return new SipProfile(c);
}
示例4: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
final SipProfile account = profileFromContextMenuInfo(menuInfo);
if(account == null) {
return;
}
WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);
// Setup the menu header
menu.setHeaderTitle(account.display_name);
if(wizardInfos != null) {
menu.setHeaderIcon(wizardInfos.icon);
}
menu.add(0, MENU_ITEM_ACTIVATE, 0, account.active ? R.string.deactivate_account
: R.string.activate_account);
menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);
}
示例5: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
// Would prefer to have this context menu view managed internal to RecentTabsGroupView
// Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
// disables the native onClick (expand/collapse) behaviour of the group view.
ExpandableListView.ExpandableListContextMenuInfo info =
(ExpandableListView.ExpandableListContextMenuInfo) menuInfo;
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
mActivity);
}
}
示例6: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)menuInfo;
String headerTitle = getContextMenuHeaderTitle(mi.position);
if (headerTitle != null) {
menu.setHeaderTitle(headerTitle);
}
List<MenuItemInfo> menus = createContextMenus(mi.id);
int i = 0;
for (MenuItemInfo m : menus) {
if (m.enabled) {
menu.add(0, m.menuId, i++, m.titleId);
}
}
}
示例7: setListViewContextMenuWithDel_Resume
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
private void setListViewContextMenuWithDel_Resume() {
lvMang.setOnCreateContextMenuListener(new OnCreateContextMenuListener() {
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
intCurrDataPos = ((AdapterContextMenuInfo) menuInfo).position;
menu.add(0, 0, 0, "删除");
menu.add(0, 1, 1, "恢复所有已暂停车次");
}
});
}
示例8: createContextMenuInfo
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
ContextMenuInfo createContextMenuInfo( View view, int flatListPosition, long id ) {
if( isHeaderOrFooterPosition( flatListPosition ) ) {
// Return normal info for header/footer view context menus
return new AdapterContextMenuInfo( view, flatListPosition, id );
}
final int adjustedPosition = getFlatPositionForConnector( flatListPosition );
ExpandableHListConnector.PositionMetadata pm = mConnector.getUnflattenedPos( adjustedPosition );
ExpandableHListPosition pos = pm.position;
id = getChildOrGroupId( pos );
long packedPosition = pos.getPackedPosition();
pm.recycle();
return new ExpandableListContextMenuInfo( view, packedPosition, id );
}
示例9: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, view, menuInfo);
// Show the name of the file in the header
AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo)menuInfo;
int position = adapterMenuInfo.position;
mActivityFileCursor.moveToPosition(position);
String path = mActivityFileCursor.getString(mDataIndex);
MetaFile file = MetaFile.from(path);
menu.setHeaderTitle(file.getName());
// Add the context menu items
menu.add(0, R.string.info, 0, R.string.info);
// Save the path, we will need it when an entry of the menu is selected
mContextMenuPath = path;
}
示例10: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
if (v.getId() != R.id.accounts_list) {
return;
}
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Account account = (Account) adapter.getItem(info.position);
menu.setHeaderTitle(account.toString());
String[] menuItems = getResources().getStringArray(R.array.account_actions);
for (int i = 0; i < menuItems.length; i++) {
menu.add(Menu.NONE, i, i, menuItems[i]);
}
}
示例11: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.volume_list_context, menu);
// Change the text of the lock/unlock item based on volume status
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
EDVolume selected = mAdapter.getItem((int) info.id);
MenuItem lockItem = menu.findItem(R.id.volume_list_menu_lock);
if (selected.isLocked()) {
lockItem.setTitle(getString(R.string.menu_unlock_volume));
} else {
lockItem.setTitle(getString(R.string.menu_lock_volume));
}
}
示例12: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
try
{
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
if (info != null)
{
fileListView.setSelection(info.position, 0);
}
menu.setHeaderTitle(R.string.fman_operation);
AdapterIf ca = getListAdapter();
ca.populateContextMenu(menu, info, fileListView.getSelected());
}
catch (Exception e)
{
e.printStackTrace();
}
}
示例13: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v.getTag() instanceof InputKeyReference) {
menu.setHeaderTitle(R.string.what_do_you_want);
menu.add(0, KEY_CONTEXT_MENU_CUT, 0, R.string.cut_key);
menu.add(0, KEY_CONTEXT_MENU_COPY, 0, R.string.copy_key);
if (minputKeyRefClipboard.isEmpty() == false) {
menu.add(0, KEY_CONTEXT_MENU_PASTE_BEFORE, 0, R.string.paste_before_key);
menu.add(0, KEY_CONTEXT_MENU_PASTE_ON, 0, R.string.paste_on_key);
menu.add(0, KEY_CONTEXT_MENU_PASTE_AFTER, 0, R.string.paste_after_key);
}
menu.add(0, KEY_CONTEXT_MENU_CREATE_BEFORE, 0, R.string.create_before_key);
menu.add(0, KEY_CONTEXT_MENU_CREATE_AFTER, 0, R.string.create_after_key);
menu.add(0, KEY_CONTEXT_MENU_DELETE, 0, R.string.delete_key);
menu.add(0, KEY_CONTEXT_MENU_EDIT, 0, R.string.edit_key);
// should not use assign, i.e. minputKeyRefUnderOpt = v.getTag()
// cause minputKeyRefUnderOpt and tag may change in different scenarios
minputKeyRefUnderOpt.copy((InputKeyReference) v.getTag());
}
}
示例14: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
getMenuInflater().inflate(R.menu.folder_context, menu);
FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position);
menu.setHeaderTitle(folder.displayName);
}
示例15: onCreateContextMenu
import android.view.ContextMenu.ContextMenuInfo; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle(R.string.accounts_context_menu_title);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
BaseAccount account = mAdapter.getItem(info.position);
if ((account instanceof Account) && !((Account) account).isEnabled()) {
getMenuInflater().inflate(R.menu.disabled_accounts_context, menu);
} else {
getMenuInflater().inflate(R.menu.accounts_context, menu);
}
if (account instanceof SearchAccount) {
for (int i = 0; i < menu.size(); i++) {
android.view.MenuItem item = menu.getItem(i);
item.setVisible(false);
}
}
else {
EnumSet<ACCOUNT_LOCATION> accountLocation = accountLocation(account);
if (accountLocation.contains(ACCOUNT_LOCATION.TOP)) {
menu.findItem(R.id.move_up).setEnabled(false);
}
else {
menu.findItem(R.id.move_up).setEnabled(true);
}
if (accountLocation.contains(ACCOUNT_LOCATION.BOTTOM)) {
menu.findItem(R.id.move_down).setEnabled(false);
}
else {
menu.findItem(R.id.move_down).setEnabled(true);
}
}
}