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