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


Java Menu類代碼示例

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


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

示例1: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (showReloadPlacesButton) {
        getMenuInflater().inflate(R.menu.main_menu, menu);
        final MenuItem myActionMenuItem = menu.findItem(R.id.action_refresh);
        myActionMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                PlaceFragment placeFragment = (PlaceFragment) getSupportFragmentManager().findFragmentById(R.id.fragment_container);
                if (placeFragment.isAdded()) {
                    placeFragment.currentPlace();
                }
                return false;
            }
        });
    }
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:OpenLocate,項目名稱:openlocate-android,代碼行數:19,代碼來源:MainActivity.java

示例2: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_switch, menu);

    // Get the action view used in your toggleservice item
    final MenuItem toggle = menu.findItem(R.id.menu_switch);
    mSwitch = (SwitchCompat) toggle.getActionView().findViewById(R.id.switchInActionBar);
    mSwitch.setEnabled(mTransportIdEditText.length() > 0 && mEmailEditText.length() > 0 &&
            mPasswordEditText.length() > 0);
    mSwitch.setChecked(mStartButton.getVisibility() != View.VISIBLE);
    mSwitch.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (((SwitchCompat) v).isChecked()) {
                checkInputFields();
            } else {
                confirmStop();
            }
        }
    });
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:ayushghd,項目名稱:iSPY,代碼行數:24,代碼來源:TrackerActivity.java

示例3: onPrepareOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);

    if (prefs.getBoolean("manage_system", false)) {
        menu.findItem(R.id.menu_app_user).setChecked(prefs.getBoolean("show_user", true));
        menu.findItem(R.id.menu_app_system).setChecked(prefs.getBoolean("show_system", false));
    } else {
        Menu submenu = menu.findItem(R.id.menu_filter).getSubMenu();
        submenu.removeItem(R.id.menu_app_user);
        submenu.removeItem(R.id.menu_app_system);
    }

    menu.findItem(R.id.menu_app_nointernet).setChecked(prefs.getBoolean("show_nointernet", true));
    menu.findItem(R.id.menu_app_disabled).setChecked(prefs.getBoolean("show_disabled", true));

    String sort = prefs.getString("sort", "name");
    if ("uid".equals(sort))
        menu.findItem(R.id.menu_sort_uid).setChecked(true);
    else
        menu.findItem(R.id.menu_sort_name).setChecked(true);

    menu.findItem(R.id.menu_lockdown).setChecked(prefs.getBoolean("lockdown", false));

    return super.onPrepareOptionsMenu(menu);
}
 
開發者ID:miankai,項目名稱:MKAPP,代碼行數:27,代碼來源:ActivityMain.java

示例4: onCreateContextMenu

import android.view.Menu; //導入依賴的package包/類
/**
 * Create the context menu.
 * @param menu The context menu.
 * @param v The view.
 * @param menuInfo The menu information.
 */
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (menu != null) {
        ((MainActivity)context).setSelectedPackageId(list.get(getLayoutPosition()).getNumber());
        Package pack = list.get(getLayoutPosition());
        menu.setHeaderTitle(pack.getName());
        // Set different title according to the data({@link Package#readable})
        if (pack.isReadable()) {
            menu.add(Menu.NONE, R.id.action_set_readable, 0, R.string.set_read);
        } else {
            menu.add(Menu.NONE, R.id.action_set_readable, 0, R.string.set_unread);
        }
        menu.add(Menu.NONE, R.id.action_copy_code, 0, R.string.copy_code);
        menu.add(Menu.NONE, R.id.action_share, 0, R.string.share);
    }
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:23,代碼來源:PackagesAdapter.java

示例5: onPanelClosed

import android.view.Menu; //導入依賴的package包/類
/**
 * Default implementation of
 * {@link android.view.Window.Callback#onPanelClosed(int, Menu)} for
 * activities. This calls through to {@link #onOptionsMenuClosed(Menu)}
 * method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
 * so that subclasses of Activity don't need to deal with feature codes.
 * For context menus ({@link Window#FEATURE_CONTEXT_MENU}), the
 * {@link #onContextMenuClosed(Menu)} will be called.
 */
public void onPanelClosed(int featureId, Menu menu) {
    switch (featureId) {
        case Window.FEATURE_OPTIONS_PANEL:
            mFragments.dispatchOptionsMenuClosed(menu);
            onOptionsMenuClosed(menu);
            break;

        case Window.FEATURE_CONTEXT_MENU:
            onContextMenuClosed(menu);
            break;

        case Window.FEATURE_ACTION_BAR:
            initWindowDecorActionBar();
            mActionBar.dispatchMenuVisibilityChanged(false);
            break;
    }
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:27,代碼來源:a.java

示例6: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@SuppressLint("SetTextI18n")
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_question_detail, menu);
        MenuItem item = menu.findItem(R.id.menu_comment);
        if (item != null) {
            View action = item.getActionView();
            if (action != null) {
                View tv = action.findViewById(R.id.tv_comment_count);
                if (tv != null) {
                    mCommentCountView = (TextView) tv;
                    if (mBean.getStatistics() != null)
                        mCommentCountView.setText(mBean.getStatistics().getComment() + "");
                }
            }
        }
//        MenuItem menuItem = menu.findItem(R.id.menu_report);
//        DrawableCompat.setTint(menuItem.getIcon(),Color.WHITE);
        return true;
    }
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:21,代碼來源:QuestionDetailActivity.java

示例7: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    if (isEnableScanFromPicture) {
        getMenuInflater().inflate(R.menu.menu_scan, menu);
        return true;
    } else {
        return super.onCreateOptionsMenu(menu);
    }
}
 
開發者ID:MRYangY,項目名稱:YZxing,代碼行數:10,代碼來源:ScannerActivity.java

示例8: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
public boolean onCreateOptionsMenu(Menu menu) {
    if(root != null && root.getChildAt(0) != null) {
        Key key = backstackHolder.getBackstack().getKey(root.getChildAt(0).getContext());
        MainActivity.get(getContext()).getMenuInflater().inflate(key.menu(), menu);
        return true;
    }
    return false;
}
 
開發者ID:Zhuinden,項目名稱:navigator,代碼行數:9,代碼來源:MainView.java

示例9: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem item = menu.findItem(R.id.action_search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
    searchView.setOnQueryTextListener(this);
}
 
開發者ID:adithya321,項目名稱:SOS-The-Healthcare-Companion,代碼行數:9,代碼來源:BaseFragment.java

示例10: onCreateActionMode

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    mode.getMenuInflater().inflate (R.menu.menu_home_contextual, menu);
    menu.findItem(R.id.home_contextual_done).setVisible( (mReminderTypeToDisplay == ViewPagerTaskDisplayType.PROGRAMMED) );
    menu.findItem(R.id.home_contextual_not_done).setVisible( (mReminderTypeToDisplay == ViewPagerTaskDisplayType.DONE) );
    return true;
}
 
開發者ID:abicelis,項目名稱:Remindy,代碼行數:8,代碼來源:HomeListFragment.java

示例11: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu items for use in the action bar
	MenuInflater inflater = getMenuInflater();
	inflater.inflate(R.menu.conversation_actions, menu);

	enableIntroductionActionIfAvailable(
			menu.findItem(R.id.action_introduction));

	return super.onCreateOptionsMenu(menu);
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:12,代碼來源:ConversationActivity.java

示例12: onMenuOpened

import android.view.Menu; //導入依賴的package包/類
/**
 * {@inheritDoc}
 *
 * @return The default implementation returns true.
 */
public boolean onMenuOpened(int featureId, Menu menu) {
    if (featureId == Window.FEATURE_ACTION_BAR) {
        initWindowDecorActionBar();
        if (mActionBar != null) {
            mActionBar.dispatchMenuVisibilityChanged(true);
        } else {
            Log.e(TAG, "Tried to open action bar menu with no action bar");
        }
    }
    return true;
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:17,代碼來源:a.java

示例13: onCreateOptionsMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    getMenuInflater().inflate(R.menu.picture_view_menu, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.action_share);

    // Fetch ShareActionProvider
    ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    if (shareActionProvider == null)
    {
        Log.w(TAG, "Failed to find share action provider");
        return false;
    }

    if(imageFilename == null)
    {
        Log.w(TAG, "No receipt to share");
        return false;
    }

    Intent shareIntent = new Intent(Intent.ACTION_SEND);

    // Determine mimetype of image
    BitmapFactory.Options opt = new BitmapFactory.Options();
    opt.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(imageFilename, opt);
    shareIntent.setType(opt.outMimeType);

    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imageFilename)));
    shareActionProvider.setShareIntent(shareIntent);

    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:brarcher,項目名稱:rental-calc,代碼行數:36,代碼來源:PictureViewActivity.java

示例14: onCreateOptionMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public boolean onCreateOptionMenu(Menu menu) {
    this.menu = menu;
    getSelfView().getCompatActivity().getMenuInflater().inflate(R.menu.menu_common, menu);
    initCollect();
    return true;
}
 
開發者ID:Mindjet,項目名稱:LiteReader,代碼行數:8,代碼來源:ZhihuStoryDetailViewModel.java

示例15: onCreateContextMenu

import android.view.Menu; //導入依賴的package包/類
@Override
public void onCreateContextMenu(ContextMenu contextMenu, View view, ContextMenu.ContextMenuInfo contextMenuInfo) {
    contextMenu.setHeaderTitle(dataList.get(contextMenuActiveItemPos).getLabel());
    contextMenu.add(Menu.NONE, 0, Menu.NONE, R.string.menu_request_icon);
    contextMenu.add(Menu.NONE, 1, Menu.NONE, R.string.menu_copy_code);
    contextMenu.add(Menu.NONE, 2, Menu.NONE, R.string.menu_save_icon);
    contextMenu.getItem(0).setOnMenuItemClickListener(this);
    contextMenu.getItem(1).setOnMenuItemClickListener(this);
    contextMenu.getItem(2).setOnMenuItemClickListener(this);

    contextMenu.getItem(0).setVisible(enableStatsModule);
}
 
開發者ID:by-syk,項目名稱:NanoIconPack,代碼行數:13,代碼來源:AppAdapter.java


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