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


Java MenuItem.getMenuInfo方法代碼示例

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


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

示例1: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
	super.onContextItemSelected(item);
       AdapterView.AdapterContextMenuInfo mi = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
       switch (item.getItemId()) {
		case MENU_UPDATE_BALANCE: {
               updateAccountBalance(mi.id);
               return true;
           }
           case MENU_PURGE_ACCOUNT: {
               Intent intent = new Intent(this, PurgeAccountActivity.class);
               intent.putExtra(PurgeAccountActivity.ACCOUNT_ID, mi.id);
               startActivityForResult(intent, PURGE_ACCOUNT_REQUEST);
               return true;
           }
		case MENU_CLOSE_OPEN_ACCOUNT: {
			Account a = em.getAccount(mi.id);
			a.isActive = !a.isActive;
			em.saveAccount(a);
			recreateCursor();
			return true;
		} 			
	}
	return false;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:26,代碼來源:AccountListActivity.java

示例2: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
    AdapterView.AdapterContextMenuInfo info;
    try {
         info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    } catch (ClassCastException e) {
        Log.e(TAG, "bad menuInfo", e);
        return false;
    }
    
    Uri noteUri = ContentUris.withAppendedId(getIntent().getData(), info.id);

    switch (item.getItemId()) {
    case R.id.context_open:
        // Launch activity to view/edit the currently selected item
        startActivity(new Intent(Intent.ACTION_EDIT, noteUri));
        return true;
    case R.id.context_delete:
        // Delete the note that the context menu is for
        getContentResolver().delete(noteUri, null, null);
        return true;
    default:
        return super.onContextItemSelected(item);
    }
}
 
開發者ID:firebase,項目名稱:firebase-testlab-instr-lib,代碼行數:26,代碼來源:NotesList.java

示例3: onMenuItemSelected

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

示例4: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
   public boolean onContextItemSelected(MenuItem item)
   {
AdapterContextMenuInfo menuInfo =
    (AdapterContextMenuInfo) item.getMenuInfo();
// TODO: Implement this method
if (item.getItemId() == 0)
{
    //預覽
    Intent intent = new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    Uri uri = Uri.fromFile(new File(curpath + "/" + files_name.get(menuInfo.position - dirs_name.size())));
    intent.setDataAndType(uri, "image/*");
    startActivity(intent);

}
return super.onOptionsItemSelected(item);
   }
 
開發者ID:stytooldex,項目名稱:stynico,代碼行數:20,代碼來源:FileList.java

示例5: onContextItemSelected

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

示例6: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
    final AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo)
            item.getMenuInfo();
    final NamedGesture gesture = (NamedGesture) menuInfo.targetView.getTag();

    switch (item.getItemId()) {
        case MENU_ID_RENAME:
            renameGesture(gesture);
            return true;
        case MENU_ID_REMOVE:
            deleteGesture(gesture);
            return true;
    }

    return super.onContextItemSelected(item);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:18,代碼來源:GestureBuilderActivity.java

示例7: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
			.getMenuInfo();
	switch (item.getItemId()) {
		case R.id.file_chooser_menu_select:
		case R.id.file_picker_menu_import:
			if (info.id >= 0) {
				EDFileChooserItem selected = mAdapter.getItem((int) info.id);
				returnResult(selected.getPath());
			}
			return true;
		default:
			return super.onContextItemSelected(item);
	}
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:16,代碼來源:EDFileChooserActivity.java

示例8: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onContextItemSelected(MenuItem item) {
	if (item.getGroupId() != ConfigUtil.DOWNLOADING_MENU_GROUP_ID) {
		return false;
	}
	
	int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;// 獲取點擊了第幾行
	DownloadInfo downloadInfo = (DownloadInfo) downloadAdapter.getItem(selectedPosition);
	String title = downloadInfo.getTitle();

	// 刪除數據庫記錄
	DataSet.removeDownloadInfo(title);

	File file = new File(Environment.getExternalStorageDirectory()+"/CCDownload", title+".mp4");
	if(file.exists()){
		file.delete();
	}
	
	// 通知service取消下載
	if (!binder.isStop() && binder.exists(title)) {
		binder.cancel(title);
		startWaitStatusDownload();
	}
	
	initData();
	downloadAdapter.notifyDataSetChanged();
	downloadingListView.invalidate();

	if (getUserVisibleHint()) {
		return true;
	}
	
	return false;
}
 
開發者ID:lbbniu,項目名稱:CCDownload,代碼行數:34,代碼來源:DownloadingFragment.java

示例9: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public boolean onContextItemSelected(MenuItem item) {
	if (item.getGroupId() != ConfigUtil.DOWNLOADED_MENU_GROUP_ID) {
		return false;
	}
	
	int selectedPosition = ((AdapterContextMenuInfo) item.getMenuInfo()).position;
	
	Pair<String, Integer> pair = (Pair<String, Integer>)videoListViewAdapter.getItem(selectedPosition);
	
	DataSet.removeDownloadInfo(pair.first);
	
	File file = new File(Environment.getExternalStorageDirectory()+"/"+ConfigUtil.DOWNLOAD_DIR, pair.first+".mp4");
	if(file.exists()){
		file.delete();
	}
	
	initData();
	videoListViewAdapter.notifyDataSetChanged();
	downloadedListView.invalidate();

	if (getUserVisibleHint()) {
		return true;
	}

	return false;
}
 
開發者ID:lbbniu,項目名稱:CCDownload,代碼行數:29,代碼來源:DownloadedFragment.java

示例10: onContextItemSelected

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

示例11: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
			.getMenuInfo();
	EDVolume selected = mAdapter.getItem((int) info.id);

	switch (item.getItemId()) {
	case R.id.volume_list_menu_lock:
		if (selected.isLocked()) {
			mSelectedVolume = selected;
			mSelectedVolIdx = info.position;
			unlockSelectedVolume();
		} else {
			selected.lock();
		}
		mAdapter.notifyDataSetChanged();
		return true;
	case R.id.volume_list_menu_rename:
		this.mSelectedVolume = selected;
		showDialog(DIALOG_VOL_RENAME);
		return true;
	case R.id.volume_list_menu_delete:
		this.mSelectedVolume = selected;
		showDialog(DIALOG_VOL_DELETE);
		return true;
	default:
		return super.onContextItemSelected(item);
	}
}
 
開發者ID:starn,項目名稱:encdroidMC,代碼行數:29,代碼來源:EDVolumeListActivity.java

示例12: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(final MenuItem menuItem)
{
	final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();

	DownloadFile downloadFile = null;

	if (info != null)
	{
		downloadFile = (DownloadFile) playlistView.getItemAtPosition(info.position);
	}

	return menuItemSelected(menuItem.getItemId(), downloadFile) || super.onContextItemSelected(menuItem);
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:15,代碼來源:DownloadActivity.java

示例13: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的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
     */
    ReaderLocation rLocation = mRLocaitonList.get(menuInfo.position);
    switch(menuItem.getItemId()) {
        case LOC_CONTEXT_MENU_MODIFY:
            Toast.makeText(getContext(), "LOC_CONTEXT_MENU_MODIFY", Toast.LENGTH_SHORT);
            ModifyLocationFragment modifyLocationFragment = new ModifyLocationFragment(rLocation, menuInfo.position);
            modifyLocationFragment.setTargetFragment(this, 0);
            modifyLocationFragment.show(mFragmentManager, "ModifyLocation");
            break;
        case LOC_CONTEXT_MENU_TAG:
            Toast.makeText(getContext(), "LOC_CONTEXT_MENU_TAG", Toast.LENGTH_SHORT);
            AssociateTagFragment associateTagFragment = new AssociateTagFragment(rLocation, menuInfo.position);
            associateTagFragment.setTargetFragment(this, 0);
            associateTagFragment.show(mFragmentManager, "AssociateTag");
            break;
        case LOC_CONTEXT_MENU_DELETE:
            Toast.makeText(getContext(), "LOC_CONTEXT_MENU_DELETE", Toast.LENGTH_SHORT);
            DeleteLocation(rLocation);
            break;
    }

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

示例14: onContextItemSelected

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

示例15: onContextItemSelected

import android.view.MenuItem; //導入方法依賴的package包/類
@Override
public boolean onContextItemSelected(MenuItem item) {
    int index = item.getItemId();
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    long listId = mBrowserAdapter.getItemId(info.position);
    switch (index) {
        case R.string.delete:
            getActivity().getContentResolver().delete(VideoStore.List.LIST_CONTENT_URI, VideoStore.List.Columns.ID +" = ?", new String[]{listId+""});
            break;
    }
    return true;
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:13,代碼來源:BrowserPlaylists.java


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