本文整理汇总了Java中android.view.ContextMenu.ContextMenuInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu.ContextMenuInfo方法的具体用法?Java ContextMenu.ContextMenuInfo怎么用?Java ContextMenu.ContextMenuInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ContextMenu
的用法示例。
在下文中一共展示了ContextMenu.ContextMenuInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
KRFAM.log("MainActivity.java > onCreateContextMenu");
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
Account contextAccount = ACCOUNT_LIST_DATA.get(info.position);
if (contextAccount.isFolder) {
menu.setHeaderTitle(contextAccount.name);
super.onCreateContextMenu(menu, v, menuInfo);
getMenuInflater().inflate(R.menu.menu_context_folder, menu);
menu.setHeaderIcon(R.drawable.ic_folder_black_24dp);
} else {
menu.setHeaderTitle(contextAccount.name);
super.onCreateContextMenu(menu, v, menuInfo);
if (contextAccount.locked) {
getMenuInflater().inflate(R.menu.menu_context_account_locked, menu);
menu.setHeaderIcon(R.drawable.ic_lock_outline_black_24dp);
} else {
getMenuInflater().inflate(R.menu.menu_context_account, menu);
}
}
}
示例2: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
// Check if the current file requires a context menu
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) menuInfo;
} catch (ClassCastException e) {
Log.e(TAG, "bad menuInfo", e);
return;
}
// This can be null sometimes, don't crash...
if (info == null) {
Log.e(TAG, "bad menuInfo");
return;
}
Object item = mFilesAdapter.getItem(info.position);
if (item instanceof MetaFile2) {
menu.setHeaderTitle(((MetaFile2) item).getName());
if (((MetaFile2) item).canWrite())
menu.add(0, R.string.delete, 0, R.string.delete);
return;
}
super.onCreateContextMenu(menu,v, menuInfo);
}
示例3: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo;
Cursor c = (Cursor) adapter.getItem(info.position);
// first item!!
int flagVal = c.getInt(c.getColumnIndex(FeedContract.Feeds.COLUMN_Flag));
if (flagVal == FeedContract.Flag.FAVORITE) {
menu.add(R.string.nofavorite);
} else {
menu.add(R.string.favorite);
}
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.item_context, menu);
}
示例4: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if(v.getTag() instanceof FtpShortcutAdapter.FtpShortcutViewHolder){
mSelectedUri =((FtpShortcutAdapter.FtpShortcutViewHolder) v.getTag()).getUri();
mSelectedName =((FtpShortcutAdapter.FtpShortcutViewHolder) v.getTag()).getName();
menu.add(0, R.string.remove_from_shortcuts, 0, R.string.remove_from_shortcuts);
menu.add(0, R.string.open_indexed_folder, 0, R.string.open_indexed_folder);
if(ShortcutDbAdapter.VIDEO.isShortcut(getActivity(), mSelectedUri.toString())<0)
menu.add(0, R.string.add_to_library, 0, R.string.add_to_library);
}
else super.onCreateContextMenu(menu, v, menuInfo);
}
示例5: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (v.getId() == android.R.id.list) {
menu.setHeaderTitle(getResources().getText(R.string.note_context_menu));
getMenuInflater().inflate(R.menu.context_menu, menu);
}
}
示例6: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo
menuInfo) {
if (v.getId() == mFileAttach.getId()) {
menu.add(0, TAKE_PHOTO, 0, R.string.take_photo);
menu.add(0, FILE_EXPLORER, 0, R.string.file_explorer);
}
}
示例7: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.setHeaderTitle("Select action");
menu.add(0, 1, 1, "Edit");
menu.add(0, 2, 2, "Delete");
}
示例8: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
WebView.HitTestResult result = webView.getHitTestResult();
if (result != null) {
int type = result.getType();
if (type == WebView.HitTestResult.IMAGE_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE) {
showLongPressedImageMenu(menu, result.getExtra());
}
}
}
示例9: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
BreventActivity activity = (BreventActivity) mFragment.getActivity();
menu.setHeaderTitle(label);
menu.add(Menu.NONE, R.string.context_menu_select, Menu.NONE,
activity.getString(R.string.context_menu_select));
menu.add(Menu.NONE, R.string.context_menu_package_name, Menu.NONE,
activity.getString(R.string.context_menu_package_name));
menu.add(Menu.NONE, R.string.context_menu_app_info, Menu.NONE,
activity.getString(R.string.context_menu_app_info));
PackageManager packageManager = mFragment.getActivity().getPackageManager();
if (BuildConfig.APPLICATION_ID.equals(packageName)) {
menu.add(Menu.NONE, R.string.context_menu_brevent_server_info, Menu.NONE,
activity.getString(R.string.context_menu_brevent_server_info));
} else if (packageManager.getLaunchIntentForPackage(packageName) != null) {
menu.add(Menu.NONE, R.string.context_menu_open, Menu.NONE,
activity.getString(R.string.context_menu_open));
}
if (activity.isBrevent(packageName)) {
if (activity.isPriority(packageName)) {
menu.add(Menu.NONE, R.string.context_menu_unset_priority, Menu.NONE,
activity.getString(R.string.context_menu_unset_priority));
} else {
menu.add(Menu.NONE, R.string.context_menu_set_priority, Menu.NONE,
activity.getString(R.string.context_menu_set_priority));
}
}
if (activity.hasOps(packageName)) {
menu.add(Menu.NONE, R.string.context_menu_appops, Menu.NONE,
activity.getString(R.string.context_menu_appops));
}
int size = menu.size();
for (int i = 0; i < size; ++i) {
menu.getItem(i).setOnMenuItemClickListener(this);
}
String important = activity.getLabel("", packageName);
if (!TextUtils.isEmpty(important)) {
menu.add(AppsLabelLoader.trim(important));
}
}
示例10: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
contextMenu.setHeaderTitle(dataList.get(contextMenuActiveItemPos).getLabel());
contextMenu.add(Menu.NONE, 0, Menu.NONE, R.string.menu_request_icon);
contextMenu.add(Menu.NONE, 1, Menu.NONE, R.string.menu_copy_code);
contextMenu.add(Menu.NONE, 2, Menu.NONE, R.string.menu_save_icon);
contextMenu.getItem(0).setOnMenuItemClickListener(this);
contextMenu.getItem(1).setOnMenuItemClickListener(this);
contextMenu.getItem(2).setOnMenuItemClickListener(this);
contextMenu.getItem(0).setVisible(enableStatsModule);
}
示例11: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
if (v.getId() == R.id.hosts_listview) {
String[] menuItems = getResources().getStringArray(R.array.list_hosts_actions);
for (int i = 0; i < menuItems.length; i++) {
menu.add(Menu.NONE, i, i, menuItems[i]);
}
}
}
示例12: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
menu.setHeaderTitle((String) ((Object[])btnMore.getTag())[0]);
Intent data = new Intent();
data.putExtra(GroupFragment.CONTEXT_MENU_KEY_INTENT_DATA_POS, (Integer) ((Object[])btnMore.getTag())[1]);
menu.add(Menu.NONE, GroupFragment.CONTEXT_MENU_EDIT, Menu.NONE, "Edit group").setIntent(data);
menu.add(Menu.NONE, GroupFragment.CONTEXT_MENU_DELETE, Menu.NONE, "Delete group").setIntent(data);
menu.add(Menu.NONE, GroupFragment.CONTEXT_MENU_LEAVE, Menu.NONE, "Leave group").setIntent(data);
}
示例13: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuItem.OnMenuItemClickListener listener = new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
String name = item.getTitle().toString();
mEtLocation.setText(name);
return true;
}
};
//clear menu
if (menu.size() != 0) {
menu.clear();
}
int id_view = v.getId();
switch (id_view) {
case R.id.arrow:
try {
mLocationList = mDbHelper.getLocationList();
} catch (NullObjectException e) {
Log.d(TAG, e.toString());
}
if (mLocationList == null || mLocationList.size() == 0) {
FunctionHelper.makeSToast(mActivity, mResources.getString(R.string.no_data_available));
} else {
int i = 0;
for (Location l : mLocationList) {
//Add menu item with groupId
menu.add(ID_GROUP_LOCATION, l.getLocation_id(), l.getLocation_id(), l.getLocation_name());
menu.getItem(i).setOnMenuItemClickListener(listener);
i++;
}
menu.setHeaderTitle(R.string.choose_a_location);
}
break;
}
}
示例14: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, ConstantValues.CONTEXT_MENU_EDIT_ID, 0, mResource.getString(R.string.gen_edit));
menu.add(0, ConstantValues.CONTEXT_MENU_DELETE_ID, 0, mResource.getString(R.string.gen_delete));
}
示例15: onCreateContextMenu
import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.imagemenu, menu);
}