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


Java AdapterView.AdapterContextMenuInfo方法代碼示例

本文整理匯總了Java中android.widget.AdapterView.AdapterContextMenuInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java AdapterView.AdapterContextMenuInfo方法的具體用法?Java AdapterView.AdapterContextMenuInfo怎麽用?Java AdapterView.AdapterContextMenuInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.AdapterView的用法示例。


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

示例1: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的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: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
	super.onCreateContextMenu(menu, v, menuInfo);
	AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)menuInfo;
	String headerTitle = getContextMenuHeaderTitle(mi.position);
	if (headerTitle != null) {
		menu.setHeaderTitle(headerTitle);
	}
	List<MenuItemInfo> menus = createContextMenus(mi.id);
	int i = 0;
	for (MenuItemInfo m : menus) {
		if (m.enabled) {
			menu.add(0, m.menuId, i++, m.titleId);				
		}
	}
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:17,代碼來源:AbstractListActivity.java

示例3: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的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

示例4: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的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

示例5: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的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

示例6: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(android.view.MenuItem item) {
    AdapterView.AdapterContextMenuInfo info =
            (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    Cursor c = (Cursor) mAdapter.getItem(info.position);
    if (c != null) {
        SipMessage msg = new SipMessage(c);
        switch (item.getItemId()) {
            case MENU_COPY: {
                clipboardManager.setText(msg.getDisplayName(), msg.getBody());
                break;
            }
            default:
                break;
        }

    }
    return super.onContextItemSelected(item);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:20,代碼來源:MessageFragment.java

示例7: onMenuItemSelected

import android.widget.AdapterView; //導入方法依賴的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

示例8: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
  if (item.getItemId() == REMOVE_FAVORITE_INDEX) {
    AdapterView.AdapterContextMenuInfo info =
        (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    roomList.remove(info.position);
    adapter.notifyDataSetChanged();
    return true;
  }

  return super.onContextItemSelected(item);
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:13,代碼來源:ConnectActivity.java

示例9: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo)
{
	super.onCreateContextMenu(menu, view, menuInfo);
	AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;

	MusicDirectory.Entry entry = (MusicDirectory.Entry) albumListView.getItemAtPosition(info.position);

	if (entry != null && entry.isDirectory())
	{
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.select_album_context, menu);
	}

	shareButton = menu.findItem(R.id.menu_item_share);

	if (shareButton != null)
	{
		shareButton.setVisible(!Util.isOffline(this));
	}

	MenuItem downloadMenuItem = menu.findItem(R.id.album_menu_download);

	if (downloadMenuItem != null)
	{
		downloadMenuItem.setVisible(!Util.isOffline(this));
	}
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:29,代碼來源:SelectAlbumActivity.java

示例10: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
  if (v.getId() == R.id.room_listview) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    menu.setHeaderTitle(roomList.get(info.position));
    String[] menuItems = getResources().getStringArray(R.array.roomListContextMenu);
    for (int i = 0; i < menuItems.length; i++) {
      menu.add(Menu.NONE, i, i, menuItems[i]);
    }
  } else {
    super.onCreateContextMenu(menu, v, menuInfo);
  }
}
 
開發者ID:Piasy,項目名稱:AppRTC-Android,代碼行數:14,代碼來源:ConnectActivity.java

示例11: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的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
     */
    final Tag tag = mTagList.get(menuInfo.position);
    switch(menuItem.getItemId()) {
        case UID_CONTEXT_MENU_MODIFY:
            // TODO
            Toast.makeText(getContext(), "Modify Tag", Toast.LENGTH_SHORT);
            ModifyTagFragment modifyTag = new ModifyTagFragment(tag, menuInfo.position);
            modifyTag.setTargetFragment(this, 0);
            modifyTag.show(mFragmentManager, "ModifyTag");
            break;

        case UID_CONTEXT_MENU_DELETE:
            /* TODO Need verify operation */
            DeleteTag(tag);
            break;
    }

    return false;
}
 
開發者ID:tjjh89017,項目名稱:DoorAccess,代碼行數:29,代碼來源:SetUIDFragment.java

示例12: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的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

示例13: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的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

示例14: onContextItemSelected

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    switch (item.getItemId()) {
        case R.id.copy_context:
            String textToCopy = adapter.getItem(info.position).getText();
            String label = "Note text";
            ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(label, textToCopy);
            clipboard.setPrimaryClip(clip);
            Toast.makeText(this, R.string.copied_to_clipboard_toast, Toast.LENGTH_SHORT).show();
            return true;
        case R.id.edit_context:
            Intent intent = new Intent(this, EditActivity.class);
            intent.putExtra(NOTE_FLAG_INTENT, adapter.getItem(info.position).getText());
            intent.putExtra(NOTE_POSITION_FLAG_INTENT, info.position);
            startActivityForResult(intent, MainActivity.REQUEST_CODE_NOTE);
            return true;
        case R.id.voice_edit_context:
            recognitionListener.setCurrentNote(adapter.getItem(info.position));
            if (voiceProcessMethod == VOICE_PROCESS_EDITOR) {
                recognitionListener.setCurrentMode(VoiceRecognitionImplementation.CHANGE_NOTE_EDITOR);
                recognitionListener.setCurrentNotePosition(info.position);
            }
            else {
                recognitionListener.setCurrentMode(VoiceRecognitionImplementation.CHANGE_NOTE_LIST);
            }
            buttonVoiceAdd.setChecked(true);
            return true;
        case R.id.delete_context:
            adapter.remove(adapter.getItem(info.position));
            Toast.makeText(this, R.string.note_deleted_toast, Toast.LENGTH_SHORT).show();
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
 
開發者ID:coffeeplanter,項目名稱:SimpleNotes,代碼行數:38,代碼來源:MainActivity.java

示例15: onCreateContextMenu

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
		ContextMenuInfo menuInfo) {
	AdapterView.AdapterContextMenuInfo info;
       try {
            info = (AdapterView.AdapterContextMenuInfo) menuInfo;
       } catch (ClassCastException e) {
           return;
       }
	Cursor cursor = (Cursor)getListAdapter().getItem(info.position);
	if (cursor == null) {
           // For some reason the requested item isn't available, do nothing
           return;
       }
       // Setup the menu header
       menu.setHeaderTitle(cursor.getString(cursor.getColumnIndex(ShoppingList.ITEM)));
       int status = cursor.getInt(cursor.getColumnIndex(ShoppingList.STATUS));
       
   	//Add context menu items depending on current state
   	switch (status) {
       case ShoppingList.OFF_LIST:
       	menu.add(0, MENU_ITEM_ON_LIST, 0, R.string.move_on_list);
       	menu.add(0, MENU_ITEM_IN_TROLLEY, 0, R.string.move_in_trolley);
       	break;
       case ShoppingList.ON_LIST:
       	menu.add(0, MENU_ITEM_IN_TROLLEY, 0, R.string.move_in_trolley);
       	menu.add(0, MENU_ITEM_OFF_LIST, 0, R.string.move_off_list);
       	break;
       case ShoppingList.IN_TROLLEY:
       	menu.add(0, MENU_ITEM_ON_LIST, 0, R.string.move_on_list);
       	menu.add(0, MENU_ITEM_OFF_LIST, 0, R.string.move_off_list);
       	break;
       }
   	
       // Add context menu items that are relevant for all items
   	menu.add(0, MENU_ITEM_EDIT, 0, R.string.edit_item);
   	menu.add(0, MENU_ITEM_DELETE, 0, R.string.delete_item);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:39,代碼來源:Trolly.java


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