當前位置: 首頁>>代碼示例>>Java>>正文


Java ContextMenu類代碼示例

本文整理匯總了Java中android.view.ContextMenu的典型用法代碼示例。如果您正苦於以下問題:Java ContextMenu類的具體用法?Java ContextMenu怎麽用?Java ContextMenu使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContextMenu類屬於android.view包,在下文中一共展示了ContextMenu類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
        MainActivity.BlockModel model = models.get(info.position);
        if (deleteList.size() > 0) {
            menu.add(0, 4, Menu.NONE, R.string.delete_selections);
            menu.add(0, 5, Menu.NONE, R.string.share_selections);
            return;
        }
        menu.add(0, 1, Menu.NONE, R.string.delete_item);
//        if (!model.className.equals("*")) {
//            menu.add(0, 2, Menu.NONE, "設為不按類名定位");
//        }
        menu.add(0, 3, Menu.NONE, R.string.share);
        menu.add(0, 6, Menu.NONE, model.enable ?R.string.disable_item: R.string.enable_item);
    }
 
開發者ID:w568w,項目名稱:fuckView,代碼行數:18,代碼來源:MainFragment.java

示例2: initializeItems

import android.view.ContextMenu; //導入依賴的package包/類
public void initializeItems(ContextMenu menu) {
	TGContext context = findContext();
	TGCaret caret = TGSongViewController.getInstance(context).getCaret();
	TGNote note = caret.getSelectedNote();
	boolean restBeat = caret.isRestBeatSelected();
	boolean running = TuxGuitar.getInstance(context).getPlayer().isRunning();
	
	this.initializeItem(menu, R.id.menu_beat_change_tied_note, this.createActionProcessor(TGChangeTiedNoteAction.NAME), !running, note != null && note.isTiedNote());
	this.initializeItem(menu, R.id.menu_beat_clean_beat, this.createActionProcessor(TGCleanBeatAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_decrement_note_semitone, this.createActionProcessor(TGDecrementNoteSemitoneAction.NAME), (!running && note != null));
	this.initializeItem(menu, R.id.menu_beat_delete_note_or_rest, this.createActionProcessor(TGDeleteNoteOrRestAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_increment_note_semitone, this.createActionProcessor(TGIncrementNoteSemitoneAction.NAME), (!running && note != null));
	this.initializeItem(menu, R.id.menu_beat_insert_rest_beat, this.createActionProcessor(TGInsertRestBeatAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_move_beats_left, this.createActionProcessor(TGMoveBeatsLeftAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_move_beats_right, this.createActionProcessor(TGMoveBeatsRightAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_remove_unused_voice, this.createActionProcessor(TGRemoveUnusedVoiceAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_beat_set_voice_auto, this.createActionProcessor(TGSetVoiceAutoAction.NAME), (!running && !restBeat));
	this.initializeItem(menu, R.id.menu_beat_set_voice_down, this.createActionProcessor(TGSetVoiceDownAction.NAME), (!running && !restBeat));
	this.initializeItem(menu, R.id.menu_beat_set_voice_up, this.createActionProcessor(TGSetVoiceUpAction.NAME), (!running && !restBeat));
	this.initializeItem(menu, R.id.menu_beat_shift_note_down, this.createActionProcessor(TGShiftNoteDownAction.NAME), (!running && note != null));
	this.initializeItem(menu, R.id.menu_beat_shift_note_up, this.createActionProcessor(TGShiftNoteUpAction.NAME), (!running && note != null));
	this.initializeItem(menu, R.id.menu_beat_stroke, new TGStrokeDialogController(), !running);
	this.initializeItem(menu, R.id.menu_beat_edit_text, new TGTextDialogController(), !running);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:25,代碼來源:TGBeatMenu.java

示例3: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
/**
 * Creates context menu for certain actions on a specific item.
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    if (v instanceof ListView) {
        ListView listView = (ListView) v;
        Object item = listView.getAdapter().getItem(info.position);
        if (item instanceof DIDLObject) {
            selectedDIDLObject = (DIDLObject) item;
        }
    }
    menu.setHeaderTitle(v.getContext().getString(
            R.string.browse_context_title));
    ArrayList<String> menuItems = new ArrayList<String>();
    menuItems.add(v.getContext().getString(R.string.browse_context_play_all));
    menuItems.add(v.getContext().getString(R.string.browse_context_play));
    //menuItems.add(v.getContext().getString( R.string.browse_context_add_to_playplist));
    menuItems.add(v.getContext()
            .getString(R.string.browse_context_download));
    for (int i = 0; i < menuItems.size(); i++) {
        menu.add(Menu.NONE, i, i, menuItems.get(i));
    }
}
 
開發者ID:theopenbit,項目名稱:yaacc-code,代碼行數:27,代碼來源:ContentListActivity.java

示例4: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
    try
    {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        if (info != null)
        {
            fileListView.setSelection(info.position, 0);
        }
        menu.setHeaderTitle(R.string.fman_operation);
        AdapterIf ca = getListAdapter();
        ca.populateContextMenu(menu, info, fileListView.getSelected());
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:20,代碼來源:Commander.java

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

示例6: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    if (!canCreateContextMenu(menu, menuInfo)) {
        return;
    }
    menu.clear();
    ViewHolder holder = (ViewHolder) ((AdapterContextMenuInfo) menuInfo).targetView.getTag();
    menu.setHeaderTitle(holder.nameView.getText());
    if (holder.icon != null) {
        setHeaderIcon(menu, holder.icon);
    }
    menu.add(Menu.NONE, R.string.app_info, Menu.NONE, R.string.app_info);
    updatePreventMenu(menu, holder.packageName);
    if (getMainIntent(holder.packageName) != null) {
        menu.add(Menu.NONE, R.string.open, Menu.NONE, R.string.open);
    }
    if (holder.canUninstall) {
        menu.add(Menu.NONE, R.string.uninstall, Menu.NONE, R.string.uninstall);
    }
    if (appNotification) {
        menu.add(Menu.NONE, R.string.app_notifications, Menu.NONE, R.string.app_notifications);
    }
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:24,代碼來源:PreventFragment.java

示例7: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {  
	super.onCreateContextMenu(menu, v, menuInfo);
	if (v.getTag() instanceof InputKeyReference)	{
		menu.setHeaderTitle(R.string.what_do_you_want);
		menu.add(0, KEY_CONTEXT_MENU_CUT, 0, R.string.cut_key);  
		menu.add(0, KEY_CONTEXT_MENU_COPY, 0, R.string.copy_key);  
		if (minputKeyRefClipboard.isEmpty() == false)	{
			menu.add(0, KEY_CONTEXT_MENU_PASTE_BEFORE, 0, R.string.paste_before_key);  
			menu.add(0, KEY_CONTEXT_MENU_PASTE_ON, 0, R.string.paste_on_key);
			menu.add(0, KEY_CONTEXT_MENU_PASTE_AFTER, 0, R.string.paste_after_key);
		}
		menu.add(0, KEY_CONTEXT_MENU_CREATE_BEFORE, 0, R.string.create_before_key);  
		menu.add(0, KEY_CONTEXT_MENU_CREATE_AFTER, 0, R.string.create_after_key);  
		menu.add(0, KEY_CONTEXT_MENU_DELETE, 0, R.string.delete_key);  
		menu.add(0, KEY_CONTEXT_MENU_EDIT, 0, R.string.edit_key); 
		// should not use assign, i.e. minputKeyRefUnderOpt = v.getTag()
		// cause minputKeyRefUnderOpt and tag may change in different scenarios
		minputKeyRefUnderOpt.copy((InputKeyReference) v.getTag());
	}
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:22,代碼來源:ActivityCfgKeyPad.java

示例8: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    switch (v.getId()) {
        case R.id.listView:
            AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

            NoteRef noteRef = mNoteRefList.get(info.position);
            boolean linked = noteRef.isLinked();
            menu.setHeaderTitle(noteRef.getTitle());

            String[] menuItems = getResources().getStringArray(R.array.notes_context_menu);
            for (int i = 0; i < menuItems.length; i++) {
                if (linked && (i == 0 || i == 3)) {
                    // share public link and delete
                    continue;
                }

                menu.add(Menu.NONE, i, i, menuItems[i]);
            }
            break;

        default:
            super.onCreateContextMenu(menu, v, menuInfo);
            break;
    }
}
 
開發者ID:fivef,項目名稱:add_to_evernote_note,代碼行數:27,代碼來源:NoteListFragment.java

示例9: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);

    int id = v.getId();
    switch (id) {
        case R.id.avatar:
            getMenuInflater().inflate(R.menu.activity_detail_teacher_change_avatar_context_menu, menu);
            menu.setHeaderTitle(R.string.change_avatar);
            view_ShowMenu = img_avatar;
            break;

        case R.id.background:
            getMenuInflater().inflate(R.menu.activity_detail_teacher_change_background_context_menu, menu);
            menu.setHeaderTitle(R.string.change_background);
            view_ShowMenu = img_background;
            break;
    }
}
 
開發者ID:nhocga1995s,項目名稱:MyCalendar,代碼行數:20,代碼來源:DetailTeacherActivity.java

示例10: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info;
    try {
         info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    } catch (ClassCastException e) {
        Log.e(THIS_FILE, "bad menuInfo", e);
        return;
    }

    HashMap<String, Object> codec = (HashMap<String, Object>) mAdapter.getItem(info.position);
    if (codec == null) {
        // If for some reason the requested item isn't available, do nothing
        return;
    }
    
    boolean isDisabled = ((Short)codec.get(CODEC_PRIORITY) == 0);
    menu.add(0, MENU_ITEM_ACTIVATE, 0, isDisabled ? R.string.activate : R.string.deactivate);
    
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:22,代碼來源:CodecsFragment.java

示例11: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    final SipProfile account = profileFromContextMenuInfo(menuInfo);
    if(account == null) {
        return;
    }
    WizardInfo wizardInfos = WizardUtils.getWizardClass(account.wizard);

    // Setup the menu header
    menu.setHeaderTitle(account.display_name);
    if(wizardInfos != null) {
        menu.setHeaderIcon(wizardInfos.icon);
    }
    
    menu.add(0, MENU_ITEM_ACTIVATE, 0, account.active ? R.string.deactivate_account
            : R.string.activate_account);
    menu.add(0, MENU_ITEM_MODIFY, 0, R.string.modify_account);
    menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_account);
    menu.add(0, MENU_ITEM_WIZARD, 0, R.string.choose_wizard);

}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:23,代碼來源:AccountsEditListFragment.java

示例12: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    mManager.getContextMenuManager().createContextMenu(
            menu, v, new ContextMenuManager.Delegate() {
                @Override
                public void openItem(int windowDisposition) {
                    mManager.openMostVisitedItem(windowDisposition, MostVisitedItem.this);
                }

                @Override
                public void removeItem() {
                    mManager.removeMostVisitedItem(MostVisitedItem.this);
                }

                @Override
                public String getUrl() {
                    return MostVisitedItem.this.getUrl();
                }

                @Override
                public boolean isItemSupported(@ContextMenuItemId int menuItemId) {
                    return true;
                }
            });
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:26,代碼來源:MostVisitedItem.java

示例13: initializeItems

import android.view.ContextMenu; //導入依賴的package包/類
public void initializeItems(ContextMenu menu) {
	TGContext context = findContext();
	TGCaret caret = TGSongViewController.getInstance(context).getCaret();
	TGTrack track = caret.getTrack();
	boolean running = TuxGuitar.getInstance(context).getPlayer().isRunning();
	
	this.initializeItem(menu, R.id.menu_track_add, this.createActionProcessor(TGAddNewTrackAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_track_remove, this.createActionProcessor(TGRemoveTrackAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_track_clone, this.createActionProcessor(TGCloneTrackAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_track_move_up, this.createActionProcessor(TGMoveTrackUpAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_track_move_down, this.createActionProcessor(TGMoveTrackDownAction.NAME), !running);
	this.initializeItem(menu, R.id.menu_track_change_solo, this.createActionProcessor(TGChangeTrackSoloAction.NAME), !running, track.isSolo());
	this.initializeItem(menu, R.id.menu_track_change_mute, this.createActionProcessor(TGChangeTrackMuteAction.NAME), !running, track.isMute());
	this.initializeItem(menu, R.id.menu_track_set_name, new TGTrackNameDialogController(), !running);
	this.initializeItem(menu, R.id.menu_track_set_channel, new TGTrackChannelDialogController(), !running);
	this.initializeItem(menu, R.id.menu_track_change_tuning, new TGTrackTuningDialogController(), !running);
}
 
開發者ID:axlecho,項目名稱:tuxguitar,代碼行數:18,代碼來源:TGTrackMenu.java

示例14: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    getMenuInflater().inflate(R.menu.folder_context, menu);

    FolderInfoHolder folder = (FolderInfoHolder) mAdapter.getItem(info.position);

    menu.setHeaderTitle(folder.displayName);
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:10,代碼來源:FolderList.java

示例15: onCreateContextMenu

import android.view.ContextMenu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    getActivity().getMenuInflater().inflate(R.menu.context_history, menu);
    if (mLastSelectedQuery != null) {
        menu.setHeaderTitle(mLastSelectedQuery.getData().from.getLocalizedName() + " - " + mLastSelectedQuery.getData().to.getLocalizedName());
    }
}
 
開發者ID:hyperrail,項目名稱:hyperrail-for-android,代碼行數:9,代碼來源:RouteSearchFragment.java


注:本文中的android.view.ContextMenu類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。