本文整理汇总了Java中android.view.MenuItem.getMenuInfo方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItem.getMenuInfo方法的具体用法?Java MenuItem.getMenuInfo怎么用?Java MenuItem.getMenuInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.MenuItem
的用法示例。
在下文中一共展示了MenuItem.getMenuInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
super.onContextItemSelected(item);
AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
switch (item.getItemId()) {
case MENU_UPDATE_BALANCE: {
updateAccountBalance(mi.id);
return true;
}
case MENU_PURGE_ACCOUNT: {
Intent intent = new Intent(this, PurgeAccountActivity.class);
intent.putExtra(PurgeAccountActivity.ACCOUNT_ID, mi.id);
startActivityForResult(intent, PURGE_ACCOUNT_REQUEST);
return true;
}
case MENU_CLOSE_OPEN_ACCOUNT: {
Account a = em.getAccount(mi.id);
a.isActive = !a.isActive;
em.saveAccount(a);
recreateCursor();
return true;
}
}
return false;
}
示例2: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
} catch (ClassCastException e) {
Log.e(TAG, "bad menuInfo", e);
return false;
}
Uri noteUri = ContentUris.withAppendedId(getIntent().getData(), info.id);
switch (item.getItemId()) {
case R.id.context_open:
// Launch activity to view/edit the currently selected item
startActivity(new Intent(Intent.ACTION_EDIT, noteUri));
return true;
case R.id.context_delete:
// Delete the note that the context menu is for
getContentResolver().delete(noteUri, null, null);
return true;
default:
return super.onContextItemSelected(item);
}
}
示例3: onMenuItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item)
{
if (featureId != Window.FEATURE_CONTEXT_MENU)
{
return false;
}
try
{
AdapterView.AdapterContextMenuInfo info;
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
if (info == null)
return false;
fileListView.setSelection(info.position, 0);
dispatchCommand(item.getItemId());
return true;
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
}
示例4: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item)
{
AdapterContextMenuInfo menuInfo =
(AdapterContextMenuInfo) item.getMenuInfo();
// TODO: Implement this method
if (item.getItemId() == 0)
{
//预览
Intent intent = new Intent("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
Uri uri = Uri.fromFile(new File(curpath + "/" + files_name.get(menuInfo.position - dirs_name.size())));
intent.setDataAndType(uri, "image/*");
startActivity(intent);
}
return super.onOptionsItemSelected(item);
}
示例5: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info;
try {
info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
} catch (ClassCastException e) {
Log.e(THIS_FILE, "bad menuInfo", e);
return false;
}
HashMap<String, Object> codec = null;
codec = (HashMap<String, Object>) mAdapter.getItem(info.position);
if (codec == null) {
// If for some reason the requested item isn't available, do nothing
return false;
}
int selId = item.getItemId();
if (selId == MENU_ITEM_ACTIVATE) {
boolean isDisabled = ((Short) codec.get(CODEC_PRIORITY) == 0);
userActivateCodec(codec, isDisabled);
return true;
}
return false;
}
示例6: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo)
item.getMenuInfo();
final NamedGesture gesture = (NamedGesture) menuInfo.targetView.getTag();
switch (item.getItemId()) {
case MENU_ID_RENAME:
renameGesture(gesture);
return true;
case MENU_ID_REMOVE:
deleteGesture(gesture);
return true;
}
return super.onContextItemSelected(item);
}
示例7: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
switch (item.getItemId()) {
case R.id.file_chooser_menu_select:
case R.id.file_picker_menu_import:
if (info.id >= 0) {
EDFileChooserItem selected = mAdapter.getItem((int) info.id);
returnResult(selected.getPath());
}
return true;
default:
return super.onContextItemSelected(item);
}
}
示例8: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onContextItemSelected(MenuItem item) {
if (item.getGroupId() != ConfigUtil.DOWNLOADING_MENU_GROUP_ID) {
return false;
}
int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;// 获取点击了第几行
DownloadInfo downloadInfo = (DownloadInfo) downloadAdapter.getItem(selectedPosition);
String title = downloadInfo.getTitle();
// 删除数据库记录
DataSet.removeDownloadInfo(title);
File file = new File(Environment.getExternalStorageDirectory()+"/CCDownload", title+".mp4");
if(file.exists()){
file.delete();
}
// 通知service取消下载
if (!binder.isStop() && binder.exists(title)) {
binder.cancel(title);
startWaitStatusDownload();
}
initData();
downloadAdapter.notifyDataSetChanged();
downloadingListView.invalidate();
if (getUserVisibleHint()) {
return true;
}
return false;
}
示例9: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean onContextItemSelected(MenuItem item) {
if (item.getGroupId() != ConfigUtil.DOWNLOADED_MENU_GROUP_ID) {
return false;
}
int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;
Pair<String, Integer> pair = (Pair<String, Integer>)videoListViewAdapter.getItem(selectedPosition);
DataSet.removeDownloadInfo(pair.first);
File file = new File(Environment.getExternalStorageDirectory()+"/"+ConfigUtil.DOWNLOAD_DIR, pair.first+".mp4");
if(file.exists()){
file.delete();
}
initData();
videoListViewAdapter.notifyDataSetChanged();
downloadedListView.invalidate();
if (getUserVisibleHint()) {
return true;
}
return false;
}
示例10: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
if (super.onContextItemSelected(item)) {
return true;
}
if (item.getItemId() == MENU_RESOLVE) {
AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
resolveAddress(mi.position, mi.id);
}
return false;
}
示例11: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
.getMenuInfo();
EDVolume selected = mAdapter.getItem((int) info.id);
switch (item.getItemId()) {
case R.id.volume_list_menu_lock:
if (selected.isLocked()) {
mSelectedVolume = selected;
mSelectedVolIdx = info.position;
unlockSelectedVolume();
} else {
selected.lock();
}
mAdapter.notifyDataSetChanged();
return true;
case R.id.volume_list_menu_rename:
this.mSelectedVolume = selected;
showDialog(DIALOG_VOL_RENAME);
return true;
case R.id.volume_list_menu_delete:
this.mSelectedVolume = selected;
showDialog(DIALOG_VOL_DELETE);
return true;
default:
return super.onContextItemSelected(item);
}
}
示例12: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(final MenuItem menuItem)
{
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
DownloadFile downloadFile = null;
if (info != null)
{
downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position);
}
return menuItemSelected(menuItem.getItemId(), downloadFile) || super.onContextItemSelected(menuItem);
}
示例13: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem menuItem) {
final AdapterView.AdapterContextMenuInfo menuInfo;
menuInfo = (AdapterView.AdapterContextMenuInfo)menuItem.getMenuInfo();
/**
* menuInfo.position for List index
* menuItem.getItemId for operation index
*/
ReaderLocation rLocation = mRLocaitonList.get(menuInfo.position);
switch(menuItem.getItemId()) {
case LOC_CONTEXT_MENU_MODIFY:
Toast.makeText(getContext(), "LOC_CONTEXT_MENU_MODIFY", Toast.LENGTH_SHORT);
ModifyLocationFragment modifyLocationFragment = new ModifyLocationFragment(rLocation, menuInfo.position);
modifyLocationFragment.setTargetFragment(this, 0);
modifyLocationFragment.show(mFragmentManager, "ModifyLocation");
break;
case LOC_CONTEXT_MENU_TAG:
Toast.makeText(getContext(), "LOC_CONTEXT_MENU_TAG", Toast.LENGTH_SHORT);
AssociateTagFragment associateTagFragment = new AssociateTagFragment(rLocation, menuInfo.position);
associateTagFragment.setTargetFragment(this, 0);
associateTagFragment.show(mFragmentManager, "AssociateTag");
break;
case LOC_CONTEXT_MENU_DELETE:
Toast.makeText(getContext(), "LOC_CONTEXT_MENU_DELETE", Toast.LENGTH_SHORT);
DeleteLocation(rLocation);
break;
}
return false;
}
示例14: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
/**
* Provides two actions: edit and hide a group
*
* @param item MenuItem
* @return
*/
@SuppressWarnings("JavaDoc")
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
// get data of row where context menu has been fired
int groupIdToRemove = info.position;
/**
* When we click on listview, we get variable "position", which counts since 0, having in mind just simple order of row.
* In order to edit group we must to define his id from database
*/
Cursor c = (Cursor) userGroupLessonsViewAdapter.getItem(groupIdToRemove);
Long id = c.getLong(c.getColumnIndexOrThrow("_id"));
// We extract name of group if user would want to edit name
String groupNameToEdit = c.getString(c.getColumnIndexOrThrow("title"));
switch (item.getItemId()) {
case R.id.context_menu_edit_group:
// edit group
Intent intent = new Intent(getApplicationContext(), FormCreateNewGroupActivity.class);
intent.putExtra("edit_group", id);
intent.putExtra("group_name", groupNameToEdit);
startActivity(intent);
return true;
case R.id.context_menu_remove_group:
// remove group. User must confirm the removing
new AlertDialog.Builder(this)
.setIcon(R.drawable.drawer_icon)
.setTitle(R.string.removing_group)
.setMessage(R.string.this_will_remove_selected_group)
.setPositiveButton(message_ok, new AlertRemoveGroupById(id))
.setNegativeButton(message_cancel, null)
.show();
return true;
default:
return super.onContextItemSelected(item);
}
}
示例15: onContextItemSelected
import android.view.MenuItem; //导入方法依赖的package包/类
@Override
public boolean onContextItemSelected(MenuItem item) {
int index = item.getItemId();
AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
long listId = mBrowserAdapter.getItemId(info.position);
switch (index) {
case R.string.delete:
getActivity().getContentResolver().delete(VideoStore.List.LIST_CONTENT_URI, VideoStore.List.Columns.ID +" = ?", new String[]{listId+""});
break;
}
return true;
}