當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。