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


Java ContextMenu.add方法代码示例

本文整理汇总了Java中android.view.ContextMenu.add方法的典型用法代码示例。如果您正苦于以下问题:Java ContextMenu.add方法的具体用法?Java ContextMenu.add怎么用?Java ContextMenu.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ContextMenu的用法示例。


在下文中一共展示了ContextMenu.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的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;
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:19,代码来源:AutoScraperActivity.java

示例2: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
	if (v.getId() == R.id.send_picture) {
		menu.add(0, MENU_PICTURE_SMALL, 0, getString(R.string.share_picture_size_small));
		menu.add(0, MENU_PICTURE_MEDIUM, 0, getString(R.string.share_picture_size_medium));
		menu.add(0, MENU_PICTURE_LARGE, 0, getString(R.string.share_picture_size_large));
		//			Not a good idea, very big pictures cause Out of Memory exceptions, slow display, ...
		//			menu.add(0, MENU_PICTURE_REAL, 0, getString(R.string.share_picture_size_real));
	} else {
		menu.add(v.getId(), MENU_DELETE_MESSAGE, 0, getString(R.string.delete));
		menu.add(v.getId(), MENU_COPY_TEXT, 0, getString(R.string.copy_text));
	}

	LinphoneChatMessage msg = getMessageForId(v.getId());
	if (msg != null && msg.getStatus() == LinphoneChatMessage.State.NotDelivered) {
		menu.add(v.getId(), MENU_RESEND_MESSAGE, 0, getString(R.string.retry));
	}
}
 
开发者ID:treasure-lau,项目名称:Linphone4Android,代码行数:19,代码来源:ChatFragment.java

示例3: 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

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

示例5: 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");
}
 
开发者ID:CMPUT301F17T29,项目名称:HabitUp,代码行数:8,代码来源:ViewHabitActivity.java

示例6: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    if (v.equals(ocrResultView)) {
        menu.add(Menu.NONE, OPTIONS_COPY_RECOGNIZED_TEXT_ID, Menu.NONE, "Copy recognized text");
        menu.add(Menu.NONE, OPTIONS_SHARE_RECOGNIZED_TEXT_ID, Menu.NONE, "Share recognized text");
    } else if (v.equals(translationView)) {
        menu.add(Menu.NONE, OPTIONS_COPY_TRANSLATED_TEXT_ID, Menu.NONE, "Copy translated text");
        menu.add(Menu.NONE, OPTIONS_SHARE_TRANSLATED_TEXT_ID, Menu.NONE, "Share translated text");
    }
}
 
开发者ID:mercuriete,项目名称:android-mrz-reader,代码行数:13,代码来源:CaptureActivity.java

示例7: 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);
}
 
开发者ID:by-syk,项目名称:NanoIconPack,代码行数:13,代码来源:AppAdapter.java

示例8: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu,
                                View v,
                                ContextMenu.ContextMenuInfo menuInfo) {
  int position = ((AdapterView.AdapterContextMenuInfo) menuInfo).position;
  if (position >= adapter.getCount() || adapter.getItem(position).getResult() != null) {
    menu.add(Menu.NONE, position, position, R.string.history_clear_one_history_text);
  } // else it's just that dummy "Empty" message
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:10,代码来源:HistoryActivity.java

示例9: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.setHeaderTitle(R.string.trans_menu_title);
    menu.add(0, 100, 0, R.string.trans_menu_changename);//groupId, itemId, order, title
    menu.add(0, 101, 0, R.string.trans_menu_viewreceiver);
    menu.add(0, 102, 0, R.string.trans_menu_openinb);
}
 
开发者ID:manuelsc,项目名称:Lunary-Ethereum-Wallet,代码行数:8,代码来源:FragmentTransactionsAbstract.java

示例10: 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));
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:41,代码来源:AppsItemViewHolder.java

示例11: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo
        menuInfo) {
    if (v.getId() == mUploadFile.getId()) {
        menu.add(0, TAKE_PHOTO, 0, R.string.take_photo);
        menu.add(0, FILE_EXPLORER, 0, R.string.file_explorer);
    }
}
 
开发者ID:metarhia,项目名称:metacom-android,代码行数:9,代码来源:FilesFragment.java

示例12: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, view, menuInfo);

    AdapterContextMenuInfo adapterMenuInfo = (AdapterContextMenuInfo)menuInfo;
    mPosition = adapterMenuInfo.position;

    ItemData itemData = getItemData(mPosition);
    if (itemData.type == ITEM_DATA_TYPE_SEPARATOR || itemData.type == ITEM_DATA_TYPE_MESSAGE) {
        // No contextual menu for separators or messages
        return;
    }

    // Show the name of the file in the header
    File file = new File(itemData.path);
    menu.setHeaderTitle(file.getName());

    if (itemData.type == ITEM_DATA_TYPE_CURRENT) {
        // Contextual menu for current subtitles files
        menu.add(0, R.string.subtitles_wizard_delete, 0, R.string.subtitles_wizard_delete);
    }
    else {
        // Contextual menu for available subtitles files
        menu.add(0, R.string.subtitles_wizard_associate, 0, R.string.subtitles_wizard_associate);
        menu.add(0, R.string.subtitles_wizard_delete, 0, R.string.subtitles_wizard_delete);
    }
}
 
开发者ID:archos-sa,项目名称:aos-Video,代码行数:28,代码来源:SubtitlesWizardActivity.java

示例13: onCreateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.setHeaderTitle(R.string.context_menu_title);
    MenuItem editMenuItem = menu.add(0, ID_EDIT, 0, R.string.edit);
    MenuItem deleteMenuItem = menu.add(0, ID_DELETE, 0, R.string.delete);

    editMenuItem.setOnMenuItemClickListener(this);
    deleteMenuItem.setOnMenuItemClickListener(this);
}
 
开发者ID:seeing-eye,项目名称:UnforgetIt,代码行数:10,代码来源:TaskViewAdapter.java

示例14: populateContextMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
@Override
public void populateContextMenu(ContextMenu menu, AdapterView.AdapterContextMenuInfo acmi, int num)
{
    try
    {
        if (readWriteAdapter)
        {
            menu.add(0, R.id.fman_action_refresh, 0, R.string.fman_refresh_title);
            menu.add(0, R.id.fman_action_create_folder, 0, R.string.fman_create_folder_title);
            if (num > 0)
            {
                menu.add(0, R.id.fman_action_rename, 0, R.string.fman_rename_title);
                menu.add(0, R.id.fman_action_delete, 0, R.string.fman_delete_title);
            }
        }
        MenuItem activeSort = null;
        menu.add(0, R.id.fman_action_sort_by_name, 0, R.string.fman_sort_by_name);
        if ((mode & MODE_SORTING) == SORT_NAME)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_name);
        }
        menu.add(0, R.id.fman_action_sort_by_ext, 0, R.string.fman_sort_by_ext);
        if ((mode & MODE_SORTING) == SORT_EXT)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_ext);
        }
        menu.add(0, R.id.fman_action_sort_by_size, 0, R.string.fman_sort_by_size);
        if ((mode & MODE_SORTING) == SORT_SIZE)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_size);
        }
        menu.add(0, R.id.fman_action_sort_by_date, 0, R.string.fman_sort_by_date);
        if ((mode & MODE_SORTING) == SORT_DATE)
        {
            activeSort = menu.findItem(R.id.fman_action_sort_by_date);
        }
        if (activeSort != null)
        {
            activeSort.setCheckable(true);
            activeSort.setChecked(true);
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:48,代码来源:AdapterBaseImpl.java

示例15: showLongPressedImageMenu

import android.view.ContextMenu; //导入方法依赖的package包/类
private void showLongPressedImageMenu(ContextMenu menu, String imageUrl) {
    mPendingImageUrlToSave = imageUrl;
    menu.add(0, ID_CONTEXT_MENU_SAVE_IMAGE, 0, getString(R.string.save_img));
    menu.add(0, ID_CONTEXT_MENU_SHARE_IMAGE, 1, getString(R.string.share_link));
}
 
开发者ID:sfilmak,项目名称:MakiLite,代码行数:6,代码来源:MessagesDesktopActivity.java


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