当前位置: 首页>>代码示例>>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;未经允许,请勿转载。