当前位置: 首页>>代码示例>>Java>>正文


Java MenuItem.getMenuInfo方法代码示例

本文整理汇总了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;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:26,代码来源:AccountListActivity.java

示例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);
    }
}
 
开发者ID:firebase,项目名称:firebase-testlab-instr-lib,代码行数:26,代码来源:NotesList.java

示例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;
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:24,代码来源:Commander.java

示例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);
   }
 
开发者ID:stytooldex,项目名称:stynico,代码行数:20,代码来源:FileList.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:27,代码来源:CodecsFragment.java

示例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);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:18,代码来源:GestureBuilderActivity.java

示例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);
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:16,代码来源:EDFileChooserActivity.java

示例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;
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:34,代码来源:DownloadingFragment.java

示例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;
}
 
开发者ID:lbbniu,项目名称:CCDownload,代码行数:29,代码来源:DownloadedFragment.java

示例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;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:12,代码来源:LocationsListActivity.java

示例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);
	}
}
 
开发者ID:starn,项目名称:encdroidMC,代码行数:29,代码来源:EDVolumeListActivity.java

示例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);
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:15,代码来源:DownloadActivity.java

示例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;
}
 
开发者ID:tjjh89017,项目名称:DoorAccess,代码行数:33,代码来源:LocationFragment.java

示例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);
    }
}
 
开发者ID:white-collar,项目名称:mobile-grammar,代码行数:44,代码来源:UserGroupLessonsActivity.java

示例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;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:13,代码来源:BrowserPlaylists.java


注:本文中的android.view.MenuItem.getMenuInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。