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


Java Menu.add方法代碼示例

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


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

示例1: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
/**
 * Create menu items such as "delete" button
 * @param menu The menu
 * @return
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    final MenuItem deleteItem = menu.add(
            Menu.NONE, DELETE_BUTTON_ID, Menu.NONE, "Delete");
    MenuItemCompat.setShowAsAction(
            deleteItem, MenuItem.SHOW_AS_ACTION_IF_ROOM);
    deleteItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            confirmDelete();
            return true;
        }
    });
    return true;
}
 
開發者ID:CMPUT301F17T13,項目名稱:cat-is-a-dog,代碼行數:21,代碼來源:ViewHabitActivity.java

示例2: smoothScrollToUserSelectedPosition

import android.view.Menu; //導入方法依賴的package包/類
public static void smoothScrollToUserSelectedPosition(final DiscreteScrollView scrollView, View anchor) {
    PopupMenu popupMenu = new PopupMenu(scrollView.getContext(), anchor);
    Menu menu = popupMenu.getMenu();
    final RecyclerView.Adapter adapter = scrollView.getAdapter();
    int itemCount = (adapter instanceof InfiniteScrollAdapter) ?
            ((InfiniteScrollAdapter) adapter).getRealItemCount() :
            adapter.getItemCount();
    for (int i = 0; i < itemCount; i++) {
        menu.add(String.valueOf(i + 1));
    }
    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int destination = Integer.parseInt(String.valueOf(item.getTitle())) - 1;
            if (adapter instanceof InfiniteScrollAdapter) {
                destination = ((InfiniteScrollAdapter) adapter).getClosestPosition(destination);
            }
            scrollView.smoothScrollToPosition(destination);
            return true;
        }
    });
    popupMenu.show();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:24,代碼來源:DiscreteScrollViewOptions.java

示例3: onPrepareOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onPrepareOptionsMenu(Menu menu)
{
    Log.v(L.TAG, "SimplyDoActivity.onPrepareOptionsMenu() called");
    
    menu.clear();
    ViewSwitcher viewSwitch = (ViewSwitcher)findViewById(R.id.ListsItemsSwitcher);
    boolean isItemDisplay = viewSwitch.getDisplayedChild() != 0;
    
    if(isItemDisplay)
    {
        MenuItem deleteInactiveMI = menu.add(Menu.NONE, DELETE_INACTIVE, Menu.NONE, "Delete Inactive");
        deleteInactiveMI.setIcon(android.R.drawable.ic_menu_delete);
    }
    
    MenuItem settingsMI = menu.add(Menu.NONE, SETTINGS, Menu.NONE, "Settings");
    settingsMI.setIcon(android.R.drawable.ic_menu_preferences);
    
    if(isItemDisplay)
    {
        MenuItem sortNowMI = menu.add(Menu.NONE, SORT_NOW, Menu.NONE, "Sort Now");
        sortNowMI.setIcon(android.R.drawable.ic_menu_sort_by_size);
    }
    
    return true;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:27,代碼來源:SimplyDoActivity.java

示例4: onPrepareOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
  public boolean onPrepareOptionsMenu(Menu menu) {
      menu.clear(); //Clear view of previous menu
menu.add(0, ITEM0, 0, getString(R.string.menu_calcassist));
menu.add(0, ITEM1, 0, getString(R.string.menu_chartmgr));
menu.add(0, ITEM2, 0, getString(R.string.menu_plotcomplicatedgraph));
menu.add(0, ITEM3, 0, getString(R.string.menu_integrate));
menu.add(0, ITEM4, 0, getString(R.string.menu_history));
if (mnSoftKeyState == ENABLE_SHOW_SOFTKEY)	{
	menu.add(0, ITEM5, 0, getString(R.string.menu_alwayshidesoftkeyboard));			
} else	{
	menu.add(0, ITEM6, 0, getString(R.string.menu_enablesoftkeyboard));			
}
menu.add(0, ITEM7, 0, getString(R.string.menu_settings));
menu.add(0, ITEM8, 0, getString(R.string.menu_help));
      return super.onPrepareOptionsMenu(menu);

  }
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:19,代碼來源:ActivitySmartCalc.java

示例5: resolveActionMode

import android.view.Menu; //導入方法依賴的package包/類
/**
 * 處理item,處理點擊
 * @param actionMode
 */
private ActionMode resolveActionMode(ActionMode actionMode) {
    if (actionMode != null) {
        final Menu menu = actionMode.getMenu();
        mActionMode = actionMode;
        menu.clear();
        for (int i = 0; i < mActionList.size(); i++) {
            menu.add(mActionList.get(i));
        }
        for (int i = 0; i < menu.size(); i++) {
            MenuItem menuItem = menu.getItem(i);
            menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    getSelectedData((String) item.getTitle());
                    releaseAction();
                    return true;
                }
            });
        }
    }
    mActionMode = actionMode;
    return actionMode;
}
 
開發者ID:CarGuo,項目名稱:CustomActionWebView,代碼行數:28,代碼來源:CustomActionWebView.java

示例6: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_main, menu);
    if (isPlaylistPage()) {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
    }
    Fragment currentFragment = getCurrentFragment();
    if (currentFragment instanceof AbsLibraryPagerRecyclerViewCustomGridSizeFragment && currentFragment.isAdded()) {
        AbsLibraryPagerRecyclerViewCustomGridSizeFragment absLibraryRecyclerViewCustomGridSizeFragment = (AbsLibraryPagerRecyclerViewCustomGridSizeFragment) currentFragment;

        MenuItem gridSizeItem = menu.findItem(R.id.action_grid_size);
        if (Util.isLandscape(getResources())) {
            gridSizeItem.setTitle(R.string.action_grid_size_land);
        }
        setUpGridSizeMenu(absLibraryRecyclerViewCustomGridSizeFragment, gridSizeItem.getSubMenu());

        menu.findItem(R.id.action_colored_footers).setChecked(absLibraryRecyclerViewCustomGridSizeFragment.usePalette());
        menu.findItem(R.id.action_colored_footers).setEnabled(absLibraryRecyclerViewCustomGridSizeFragment.canUsePalette());
    } else {
        menu.add(0, R.id.action_new_playlist, 0, R.string.new_playlist_title);
        menu.removeItem(R.id.action_grid_size);
        menu.removeItem(R.id.action_colored_footers);
    }
    colorToolbar();
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:27,代碼來源:LibraryFragment.java

示例7: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater inflater2 = getMenuInflater();
    inflater2.inflate(R.menu.play, menu);

    MenuInflater inflater7 = getMenuInflater();
    inflater7.inflate(R.menu.save, menu);

    MenuInflater inflater4 = getMenuInflater();
    inflater4.inflate(R.menu.discard, menu);
    MenuInflater inflater6 = getMenuInflater();
    inflater6.inflate(R.menu.settings, menu);
    menu.add(1, ABOUT, 0, R.string.about_menu_short);
    return true;
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:17,代碼來源:TrackOnlinePlaylistBrowser.java

示例8: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();
    preventMenu = menu.add(Menu.NONE, R.string.prevent, Menu.NONE, R.string.prevent);
    preventMenu.setIcon(R.drawable.ic_menu_prevent);
    preventMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    preventMenu.setVisible(false);
    removeMenu = menu.add(Menu.NONE, R.string.remove, Menu.NONE, R.string.remove);
    removeMenu.setIcon(R.drawable.ic_menu_recover);
    removeMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    removeMenu.setVisible(false);
    menu.add(Menu.NONE, R.string.switch_theme, Menu.NONE, R.string.switch_theme);
    menu.add(Menu.NONE, R.string.report_bug, Menu.NONE, R.string.report_bug);
    menu.add(Menu.NONE, R.string.user_guide, Menu.NONE, R.string.user_guide);
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:brevent,項目名稱:prevent,代碼行數:17,代碼來源:PreventActivity.java

示例9: onPrepareOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
  public boolean onPrepareOptionsMenu(Menu menu) {
      menu.clear(); //Clear view of previous menu
menu.add(0, Menu.FIRST, 0, getString(R.string.menu_fill_example));
if (mnSoftKeyState == ENABLE_SHOW_SOFTKEY)	{
	menu.add(0, Menu.FIRST + 1, 0, getString(R.string.hide_system_soft_key));			
} else	{
	menu.add(0, Menu.FIRST + 1, 0, getString(R.string.pop_up_system_soft_key));			
}
menu.add(0, Menu.FIRST + 2, 0, getString(R.string.menu_help));
  	return super.onPrepareOptionsMenu(menu);
  }
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:13,代碼來源:ActivityPlotXYGraph.java

示例10: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
/*
 * Create menus
 */
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	menu.add(0, ITEM0, 0, getString(R.string.menu_add));
	menu.add(0, ITEM1, 0, getString(R.string.menu_addleft));
	menu.add(0, ITEM2, 0, getString(R.string.menu_addright));
	menu.add(0, ITEM3, 0, getString(R.string.menu_delete));
	menu.add(0, ITEM4, 0, getString(R.string.menu_save));
	menu.add(0, ITEM5, 0, getString(R.string.menu_help));
	return true;
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:15,代碼來源:ActivityCfgKeyPad.java

示例11: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	MenuItem menuItem = menu.add(0, MENU_PREFERENCES, 0, R.string.preferences);
	menuItem.setIcon(android.R.drawable.ic_menu_preferences);
	return true;
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:8,代碼來源:Report2DChartActivity.java

示例12: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    if (!inflateMenuItems)
        return super.onCreateOptionsMenu(menu);

    // Adding the add user option only if group chat is enabled.
    if (BDefines.Options.GroupEnabled)
    {
        MenuItem item =
                menu.add(Menu.NONE, R.id.action_chat_sdk_add, 10, getString(R.string.chat_activity_show_users_item_text));
        item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        item.setIcon(R.drawable.ic_plus);
    }

    if (BDefines.Options.ThreadDetailsEnabled)
    {

        MenuItem itemThreadUsers =
            menu.add(Menu.NONE, R.id.action_chat_sdk_thread_details, 10, getString(R.string.chat_activity_show_thread_details));
        
        itemThreadUsers.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        itemThreadUsers.setIcon(android.R.drawable.ic_menu_info_details);
    }
    
    return super.onCreateOptionsMenu(menu);
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:28,代碼來源:ChatSDKAbstractChatActivity.java

示例13: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
@Override
  public boolean onCreateOptionsMenu(Menu menu) {
    if (App.fejlsøgning) {
      menu.add(0, 644, 0, "Hent nyeste udvikler-version");
      menu.add(0, 642, 0, "Fejlsøgning");
      menu.add(0, 643, 0, "Vis log");
      menu.add(0, 646, 0, "Send fejlrapport");
      menu.add(0, 647, 0, "Fremtving crash (og send rapport)");
//      menu.add(0, 2645, 0, "Status på hentninger");
      menu.add(0, 13643, 0, "Vis servertid");
    }
    return super.onCreateOptionsMenu(menu);
  }
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:14,代碼來源:Basisaktivitet.java

示例14: onCreateOptionsMenu

import android.view.Menu; //導入方法依賴的package包/類
/**
 * Called when your activity's options menu needs to be created.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    menu.add(Menu.NONE, MENU_SPEEDDOWN, Menu.NONE, "Slower");
    menu.add(Menu.NONE, MENU_SPEEDUP,   Menu.NONE, "Faster");
    menu.add(Menu.NONE, MENU_FRAMES,    Menu.NONE, "Show Frames");
    menu.add(Menu.NONE, MENU_RESTART,   Menu.NONE, "Restart");
    menu.add(Menu.NONE, MENU_EXIT,      Menu.NONE, "Exit");
    return true;
}
 
開發者ID:zipzapdat,項目名稱:AndroFish,代碼行數:14,代碼來源:AndroidFishEatingFish.java

示例15: onCreateOptionsMenu

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

    menu.add(0, R.string.add_ssh_server, 0, R.string.add_ssh_server);
    if(mCurrentDirectory!=null){
       MenuItem mi;
        if(ShortcutDb.STATIC.isShortcut(getActivity(), mCurrentDirectory.toString())<=0)
            mi= menu.add(0,R.string.add_ssh_shortcut, 0,R.string.add_ssh_shortcut);
        else
            mi= menu.add(0,R.string.remove_from_shortcuts, 0,R.string.remove_from_shortcuts);
       mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
    if(getActivity() instanceof MainActivity) {
        mSearchView = ((MainActivity) getActivity()).getSearchView();
        mSearchView.setSearchableInfo(null);
        mSearchView.setQuery("", true);//resetting query
        mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
            boolean isFirstEntryTextChange = true;


            @Override
            public boolean onQueryTextChange(String newText) {
                if (!isFirstEntryTextChange)
                    filter(newText);
                isFirstEntryTextChange = false;
                return true;
            }

            @Override
            public boolean onQueryTextSubmit(String query) {

                return true;
            }
        });
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:38,代碼來源:BrowserBySFTP.java


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