android.view.MenuItem#getMenuInfo ( )源码实例Demo

下面列出了android.view.MenuItem#getMenuInfo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: VCL-Android   文件: HistoryFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    if(!getUserVisibleHint()) return super.onContextItemSelected(item);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if(info == null) // info can be null
        return super.onContextItemSelected(item);
    int id = item.getItemId();

    if(id == R.id.history_view_play) {
        playListIndex(info.position);
        return true;
    } else if(id == R.id.history_view_delete) {
        mHistoryAdapter.remove(info.position);
        return true;
    }
    return super.onContextItemSelected(item);
}
 
源代码2 项目: beaconloc   文件: DetectedBeaconsFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    ContextMenuRecyclerView.RecyclerContextMenuInfo info = (ContextMenuRecyclerView
            .RecyclerContextMenuInfo) item
            .getMenuInfo();

    switch (item.getItemId()) {
        case R.id.action_manage_add:
            selectBeacon(new TrackedBeacon((IManagedBeacon) mBeaconsAdapter.getItem(info.position)));
            return true;
        case R.id.action_filter_add:
            //TODO
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }

}
 
源代码3 项目: odyssey   文件: ArtistAlbumsFragment.java
/**
 * Hook called when an menu item in the context menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 */
@Override
public boolean onContextItemSelected(@NonNull MenuItem item) {
    OdysseyRecyclerView.RecyclerViewContextMenuInfo info =
            (OdysseyRecyclerView.RecyclerViewContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
        case R.id.fragment_artist_albums_action_enqueue:
            enqueueAlbum(info.position);
            return true;
        case R.id.fragment_artist_albums_action_play:
            playAlbum(info.position);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
 
源代码4 项目: budget-watch   文件: BudgetActivity.java
@Override
public boolean onContextItemSelected(MenuItem item)
{
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
    ListView listView = (ListView) findViewById(R.id.list);

    if(info != null)
    {
        Budget budget = (Budget) listView.getItemAtPosition(info.position);

        if (budget != null && item.getItemId() == R.id.action_edit)
        {
            Intent i = new Intent(getApplicationContext(), BudgetViewActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("id", budget.name);
            bundle.putBoolean("view", true);
            i.putExtras(bundle);
            startActivity(i);

            return true;
        }
    }

    return super.onContextItemSelected(item);
}
 
源代码5 项目: microMathematics   文件: Commander.java
@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;
    }
}
 
源代码6 项目: sniffer154   文件: SessionManagerActivity.java
@Override
	public boolean onContextItemSelected(MenuItem item) {
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
				.getMenuInfo();
		switch (item.getItemId()) {
		case R.id.itemLoad:
			loadSession(info.id);
			return true;
		case R.id.itemDelete:
			deleteSession(info.id);
			return true;
//		case R.id.itemExport:
//			exportSession(info.id);
//			return true;
		default:
			return false;
		}
	}
 
源代码7 项目: android   文件: MainActivity.java
@Override
public boolean onContextItemSelected(MenuItem item) {
	
	/*
	 *  Contiene información sobre el elemento del menú contextual
	 *  sobre el que se ha pulsado
	 */
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
	
	switch (item.getItemId()) {
		case R.id.ctx_eliminar:
			
			eliminarContacto(info);
			return true;
		default:
			return super.onContextItemSelected(item);
	}
}
 
源代码8 项目: stynico   文件: FileList.java
@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);
   }
 
源代码9 项目: ampdroid   文件: PlaylistsView.java
@Override
public boolean onContextItemSelected(MenuItem item) {
	AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
	Playlist selected = controller.getPlaylists().get((int) info.id);
	String urlString = controller.getServer().getHost() + "/server/xml.server.php?action=playlist_songs&auth="
			+ controller.getServer().getAuthKey() + "&filter=" + String.valueOf(selected.getId());
	Log.d("url", urlString);
	switch (item.getItemId()) {
	case R.id.contextMenuAdd:
		controller.parsePlaylistSongs(urlString, controller.getPlayNow());
		Context context = getView().getContext();
		CharSequence text = getResources().getString(R.string.playlistsViewPlaylistAdded);
		int duration = Toast.LENGTH_SHORT;
		Toast toast = Toast.makeText(context, text, duration);
		toast.show();
		return true;
	case R.id.contextMenuOpen:
		controller.getSelectedSongs().clear();
		controller.parsePlaylistSongs(urlString, controller.getSelectedSongs());
		// Create new fragment and transaction
		SelectedSongsView newFragment = new SelectedSongsView();
		FragmentTransaction transaction = getActivity().getSupportFragmentManager().beginTransaction();

		// Replace whatever is in the fragment_container view with this fragment,
		// and add the transaction to the back stack
		transaction.replace(R.id.content_frame, newFragment);
		transaction.addToBackStack(null);

		// Commit the transaction
		transaction.commit();
		return true;
	default:
		return super.onContextItemSelected(item);
	}
}
 
源代码10 项目: something.apk   文件: PrivateMessageListFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()){
        case R.id.menu_delete:
            AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
            FastItem pm = adapter.getItem(info.position);
            if(pm != null){
                queueRequest(new PMDeleteRequest(folderId, deleteListener, null, pm.getId()));
                return true;
            }
    }
    return super.onContextItemSelected(item);
}
 
@Override
public boolean onContextItemSelected(MenuItem item) {
	switch (item.getItemId()) {
	case DELETE_ID:
		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
				.getMenuInfo();
		Uri uri = Uri.parse(MyTodoContentProvider.CONTENT_URI + "/"
				+ info.id);
		getContentResolver().delete(uri, null, null);
		fillData();
		return true;
	}
	return super.onContextItemSelected(item);
}
 
源代码12 项目: odyssey   文件: AlbumTracksFragment.java
/**
 * Hook called when an menu item in the context menu is selected.
 *
 * @param item The menu item that was selected.
 * @return True if the hook was consumed here.
 */
@Override
public boolean onContextItemSelected(@NonNull MenuItem item) {
    OdysseyRecyclerView.RecyclerViewContextMenuInfo info =
            (OdysseyRecyclerView.RecyclerViewContextMenuInfo) item.getMenuInfo();

    if (info == null) {
        return super.onContextItemSelected(item);
    }

    switch (item.getItemId()) {
        case R.id.fragment_album_tracks_action_play:
            playTrack(info.position);
            return true;
        case R.id.fragment_album_tracks_action_enqueue:
            enqueueTrack(info.position, false);
            return true;
        case R.id.fragment_album_tracks_action_enqueueasnext:
            enqueueTrack(info.position, true);
            return true;
        case R.id.fragment_album_tracks_action_showartist:
            showArtist(info.position);
            return true;
        default:
            return super.onContextItemSelected(item);
    }
}
 
源代码13 项目: Overchan-Android   文件: AutohideActivity.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.context_menu_delete) {
        if (item.getMenuInfo() != null && item.getMenuInfo() instanceof AdapterView.AdapterContextMenuInfo) {
            int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
            if (position > 0) {
                rulesJson.remove(position-1);
                rulesChanged();
            }
        }
    }
    return super.onContextItemSelected(item);
}
 
源代码14 项目: Overchan-Android   文件: NewTabFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    int position = ((AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position;
    switch (item.getItemId()) {
        case R.id.context_menu_quickaccess_move:
            adapter.setDraggingItem(position);
            return true;
        case R.id.context_menu_quickaccess_remove:
            list.remove(position);
            adapter.notifyDataSetChanged();
            saveQuickAccessToPreferences();
            return true;
    }
    return false;
}
 
源代码15 项目: Task-Reminder-App   文件: ReminderListActivity.java
@Override
public boolean onContextItemSelected(MenuItem item) {
	switch(item.getItemId()) {
   	case R.id.menu_delete:
   		AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
        mDbHelper.deleteReminder(info.id);
        fillData();
        return true;
	}
	return super.onContextItemSelected(item);
}
 
源代码16 项目: commcare-android   文件: FormRecordListActivity.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    try {
        AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo();
        FormRecord selectedRecord = (FormRecord)adapter.getItem(info.position);
        switch (item.getItemId()) {
            case OPEN_RECORD:
                returnItem(info.position);
                return true;
            case DELETE_RECORD:
                FormRecord toDelete =
                        CommCareApplication.instance().getUserStorage(FormRecord.class).read((int)info.id);
                toDelete.logPendingDeletion(TAG, "the user manually selected 'DELETE' in FormRecordListActivity");
                FormRecordCleanupTask.wipeRecord(toDelete);
                listView.post(adapter::notifyDataSetInvalidated);
                return true;
            case RESTORE_RECORD:
                new FormRecordProcessor(this).updateRecordStatus(selectedRecord, FormRecord.STATUS_UNSENT);
                adapter.resetRecords();
                adapter.notifyDataSetChanged();
                return true;
            case SCAN_RECORD:
                FormRecord theRecord = (FormRecord)adapter.getItem(info.position);
                Pair<Boolean, String> result = new FormRecordProcessor(this).verifyFormRecordIntegrity(theRecord);
                createFormRecordScanResultDialog(result, theRecord);
                logIntegrityScanResult(theRecord, result);
                return true;
            case VIEW_QUARANTINE_REASON:
                createQuarantineReasonDialog(selectedRecord);
                return true;
        }
        return true;
    } catch (SessionUnavailableException e) {
        //TODO: Login and try again
        return true;
    }
}
 
源代码17 项目: ExpandableRecyclerView   文件: SingleRvFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableRecyclerView.ExpandableRecyclerViewContextMenuInfo menuInfo =
            (ExpandableRecyclerView.ExpandableRecyclerViewContextMenuInfo) item.getMenuInfo();
    Logger.e(TAG, menuInfo.toString());
    return true;
}
 
源代码18 项目: VCL-Android   文件: AudioBrowserFragment.java
@Override
public boolean onContextItemSelected(MenuItem menu) {
    if(!getUserVisibleHint())
        return super.onContextItemSelected(menu);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menu.getMenuInfo();
    if (info != null && handleContextItemSelected(menu, info.position))
        return true;
    return super.onContextItemSelected(menu);
}
 
源代码19 项目: LyricHere   文件: LyricExplorerFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    boolean handled = false;
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    // info.id will return row id
    // select * from lyric where title like "De%";

    Cursor cursor = (Cursor) mAdapter.getItem(info.position);
    String path = cursor.getString(cursor.getColumnIndex(Constants.Column.PATH));
    switch (item.getItemId()) {
        case R.id.menu_encoding_big5:
            new LyricEncodingUpdater(getActivity()).execute(path,
                    cursor.getString(cursor.getColumnIndex(Constants.Column.ID)),
                    Constants.ENCODE_BIG5);
            handled = true;
            break;
        case R.id.menu_encoding_gbk:
            new LyricEncodingUpdater(getActivity()).execute(path,
                    cursor.getString(cursor.getColumnIndex(Constants.Column.ID)),
                    Constants.ENCODE_GBK);
            handled = true;
            break;
        case R.id.menu_encoding_sjis:
            new LyricEncodingUpdater(getActivity()).execute(path,
                    cursor.getString(cursor.getColumnIndex(Constants.Column.ID)),
                    Constants.ENCODE_SJIS);
            handled = true;
            break;
        case R.id.menu_encoding_utf_8:
            new LyricEncodingUpdater(getActivity()).execute(path,
                    cursor.getString(cursor.getColumnIndex(Constants.Column.ID)),
                    Constants.ENCODE_UTF_8);
            handled = true;
            break;
        default:
            break;
    }
    if (handled) {
        return true;
    } else {
        return super.onContextItemSelected(item);
    }
}
 
源代码20 项目: ActivityLauncher   文件: AllTasksListFragment.java
@Override
public boolean onContextItemSelected(MenuItem item) {
    ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
    ExpandableListView list = getView().findViewById(R.id.expandableListView1);

    switch (ExpandableListView.getPackedPositionType(info.packedPosition)) {
        case ExpandableListView.PACKED_POSITION_TYPE_CHILD:
            MyActivityInfo activity = (MyActivityInfo) list.getExpandableListAdapter().getChild(ExpandableListView.getPackedPositionGroup(info.packedPosition), ExpandableListView.getPackedPositionChild(info.packedPosition));
            switch (item.getItemId()) {
                case 0:
                    LauncherIconCreator.createLauncherIcon(getActivity(), activity);
                    break;
                case 1:
                    LauncherIconCreator.launchActivity(getActivity(), activity.component_name);
                    break;
                case 2:
                    DialogFragment dialog = new ShortcutEditDialogFragment();
                    Bundle args = new Bundle();
                    args.putParcelable("activity", activity.component_name);
                    dialog.setArguments(args);
                    dialog.show(getFragmentManager(), "ShortcutEditor");
                    break;
            }
            break;

        case ExpandableListView.PACKED_POSITION_TYPE_GROUP:
            MyPackageInfo pack = (MyPackageInfo) list.getExpandableListAdapter().getGroup(ExpandableListView.getPackedPositionGroup(info.packedPosition));
            switch (item.getItemId()) {
                case 0:
                    boolean success = LauncherIconCreator.createLauncherIcon(getActivity(), pack);
                    Toast.makeText(getActivity(), getString(R.string.error_no_default_activity), Toast.LENGTH_LONG).show();
                    break;
                case 1:
                    PackageManager pm = getActivity().getPackageManager();
                    Intent intent = pm.getLaunchIntentForPackage(pack.package_name);
                    if (intent != null) {
                        Toast.makeText(getActivity(), String.format(getText(R.string.starting_application).toString(), pack.name), Toast.LENGTH_LONG).show();
                        getActivity().startActivity(intent);
                    } else {
                        Toast.makeText(getActivity(), getString(R.string.error_no_default_activity), Toast.LENGTH_LONG).show();
                    }
                    break;
            }
    }
    return super.onContextItemSelected(item);
}