@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    super.onCreateOptionsMenu(menu, inflater);

    inflater.inflate(R.menu.menu_timeline_fragment, menu);

    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.action_edit), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.action_refresh), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (!openAsDialog()) {
      MenuItem itemReload = menu.add(0, RELOAD_ID, 0, R.string.shared_string_refresh);
      itemReload.setIcon(R.drawable.ic_action_refresh_dark);
      MenuItemCompat.setShowAsAction(itemReload, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);

      MenuItem itemSearch = menu.add(0, SEARCH_ID, 1, R.string.shared_string_search);
      itemSearch.setIcon(R.drawable.ic_action_search_dark);
      MenuItemCompat.setShowAsAction(itemSearch, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    }
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    optionsMenu = menu;

    // 收藏按钮
    MenuItem favoriteItem = menu.add(0, FAVORITE_ITEM_ID, 100, R.string.footbar_favorite);
    favoriteItem.setIcon(R.drawable.ic_menu_favorite_n);
    MenuItemCompat.setShowAsAction(favoriteItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);

    // 分享按钮
    MenuItem shareItem = menu.add(0, SHARE_ITEM_ID, 101, R.string.footbar_share);
    MenuItemCompat.setActionProvider(shareItem, mShareActionProvider);
    MenuItemCompat.setShowAsAction(shareItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    return true;
  }
  protected void updateUserHeader() {
    final MenuItem userHeaderMenu =
        (mOptionsMenu != null) ? mOptionsMenu.findItem(R.id.menu_user_header) : null;
    if (userHeaderMenu != null) {
      View userHeaderView = MenuItemCompat.getActionView(userHeaderMenu);
      if (userHeaderView == null) {
        userHeaderView = getLayoutInflater().inflate(R.layout.actionbar_user_header, null, false);
        userHeaderView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                onOptionsItemSelected(userHeaderMenu);
              }
            });
        MenuItemCompat.setShowAsAction(userHeaderMenu, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
        MenuItemCompat.setActionView(userHeaderMenu, userHeaderView);
      }
      UserHeader header = Session.getInstance().getCustomerHeader();
      if (header != null) {
        ((TextView) userHeaderView.findViewById(R.id.text1)).setText("hi");

        userHeaderMenu.setTitle(header.userName.getUserNameDisplay());
        userHeaderMenu.setVisible(true);
      } else {
        userHeaderMenu.setTitle("Login");
        userHeaderMenu.setVisible(false);
      }
    }
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuItemCompat.setShowAsAction(
       menu.add(0, MENU_RANDOM, 1, R.string.menu_random).setIcon(R.drawable.ic_menu_shuffle),
       MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
   return super.onCreateOptionsMenu(menu);
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem overflowItem = menu.add(0, MENU_OVERFLOW, 0, null);
    MenuItemCompat.setShowAsAction(overflowItem, MenuItem.SHOW_AS_ACTION_ALWAYS);

    overflowItem.setIcon(R.drawable.ic_menu_moreoverflow_normal_holo_light);
    return true;
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   MenuInflater inflater = getMenuInflater();
   inflater.inflate(R.menu.number_validation_menu, menu);
   MenuItem item = menu.findItem(R.id.menu_settings);
   MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
   return true;
 }
예제 #8
0
 private void addSettingItem(Menu menu) {
   mMenu = menu.add(Menu.NONE, PopupWindowBuilder.ID_MENU_SETTING, 100, "");
   mMenu.setIcon(R.mipmap.ic_menu_more);
   mMenu.setOnMenuItemClickListener(this);
   // mMenu.setShowAsActionFlags(MenuItem.SHOW_AS_ACTION_ALWAYS);
   MenuItemCompat.setShowAsAction(mMenu, MenuItem.SHOW_AS_ACTION_ALWAYS);
   mMenu.setVisible(isMenuVisible);
 }
예제 #9
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    final int category = 0;
    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_FAVORITE, 1, R.string.menu_favorite_remove)
            .setIcon(R.drawable.ic_menu_not_favorited),
        MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_ZOOM, 4, R.string.menu_zoom).setIcon(R.drawable.ic_menu_zoom),
        MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_SAVE, 3, R.string.menu_download).setIcon(R.drawable.ic_menu_save),
        MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_SHARE, 2, R.string.menu_share).setIcon(R.drawable.ic_menu_share),
        MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    if (getActivity() != null && getActivity() instanceof DilbertFavoritedActivity) {
      MenuItemCompat.setShowAsAction(
          menu.add(category, MENU_OPEN_AT, 5, R.string.menu_open_at)
              .setIcon(R.drawable.ic_menu_open_at),
          MenuItemCompat.SHOW_AS_ACTION_NEVER);
    }
    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_REFRESH, 4, R.string.menu_refresh)
            .setIcon(R.drawable.ic_menu_refresh),
        MenuItemCompat.SHOW_AS_ACTION_NEVER);

    MenuItemCompat.setShowAsAction(
        menu.add(category, MENU_OPEN_IN_BROWSER, 3, R.string.menu_open_in_browser)
            .setIcon(R.drawable.ic_menu_open_at),
        MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
  }
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   getMenuInflater().inflate(R.menu.image, menu);
   MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
   if (ActionBarUtil.hasSB()) {
     MenuItemCompat.setShowAsAction(actionItem, MenuItemCompat.SHOW_AS_ACTION_NEVER);
   }
   ShareActionProvider actionProvider =
       (ShareActionProvider) MenuItemCompat.getActionProvider(actionItem);
   actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
   actionProvider.setShareIntent(createShareIntent());
   return super.onCreateOptionsMenu(menu);
 }
예제 #11
0
  void initializeLoadingIndicator(Menu OptionsMenu) {
    // Add refresh in Action Bar
    mLoadingItem = OptionsMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, getString(R.string.loading));

    // Set up the view
    MenuItemCompat.setActionView(mLoadingItem, R.layout.loading);

    // Specify the show flags
    MenuItemCompat.setShowAsAction(mLoadingItem, MenuItem.SHOW_AS_ACTION_ALWAYS);

    // Hide by default
    mLoadingItem.setVisible(false);
  }
 @Override
 public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
   MenuItem accept =
       menu.add(Menu.NONE, MENU_ACCEPT, Menu.NONE, R.string.folder_picker_select_this)
           .setIcon(R.drawable.ic_navigation_accept);
   MenuItemCompat.setShowAsAction(accept, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
   menu.add(Menu.NONE, MENU_SHOW_HIDDEN, Menu.NONE, R.string.folder_picker_show_hidden)
       .setCheckable(true);
   menu.add(Menu.NONE, MENU_SHOW_FILES, Menu.NONE, R.string.folder_picker_show_files)
       .setCheckable(true);
   menu.add(Menu.NONE, MENU_GO_DEFAULT, Menu.NONE, R.string.folder_picker_go_to_default);
   super.onCreateOptionsMenu(menu, inflater);
 }
예제 #13
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.script_menu, menu);
    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_add), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setActionProvider(
        menu.findItem(R.id.script_add), new AddActionProvider(this)); // 自定义子菜单

    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_view), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setShowAsAction(
        menu.findItem(R.id.script_setting), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItem item = menu.findItem(R.id.script_search);
    SearchView searchView = new SearchView(this.getSupportActionBar().getThemedContext());
    MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
    MenuItemCompat.setActionView(item, searchView); // 设置搜索窗口
    searchView.setOnQueryTextListener(
        new OnQueryTextListener() {
          @Override
          public boolean onQueryTextSubmit(String query) {
            mInSearchResultMode = true;
            updateAndFilterScriptList(query);
            mAdapter.notifyDataSetChanged();
            return false;
          }

          @Override
          public boolean onQueryTextChange(String query) {
            mInSearchResultMode = true;
            updateAndFilterScriptList(query);
            mAdapter.notifyDataSetChanged();
            return false;
          }
        });
    return true;
  }
예제 #14
0
  @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_activity_orders, menu);

    // Search Icon referenzieren
    searchItem = menu.findItem(R.id.itm_action_search);

    MenuItemCompat.setActionView(searchItem, searchView);
    MenuItemCompat.setShowAsAction(
        searchItem,
        MenuItemCompat.SHOW_AS_ACTION_ALWAYS | MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW);

    return super.onCreateOptionsMenu(menu);
  }
예제 #15
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem item =
        menu.add(R.string.new_list)
            .setOnMenuItemClickListener(
                new MenuItem.OnMenuItemClickListener() {
                  @Override
                  public boolean onMenuItemClick(MenuItem item) {
                    listener.onNewListClicked();
                    return true;
                  }
                });
    MenuItemCompat.setShowAsAction(item, SHOW_AS_ACTION_IF_ROOM | SHOW_AS_ACTION_WITH_TEXT);
  }
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.share_action_provider, menu);

    // Set file with share history to the provider and set the share intent.
    MenuItem menuItem_Share = menu.findItem(R.id.action_share);
    shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem_Share);
    shareAction.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);

    MenuItem menuItem_Star = menu.add(0, MENU_ITEM_STAR, menu.size(), R.string.description_star);
    MenuItemCompat.setShowAsAction(menuItem_Star, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);

    if (mIsStarred) {
      menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star_on);
    } else {
      menu.getItem(MENU_ITEM_STAR).setIcon(R.drawable.ic_menu_star);
    }
  }
예제 #17
0
  @Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.menu_main_search, menu); // removed to not double the menu items
    MenuItem item = menu.findItem(R.id.menu_search);
    SearchView sv =
        new SearchView(((MainActivity) getActivity()).getSupportActionBar().getThemedContext());
    MenuItemCompat.setShowAsAction(
        item,
        MenuItemCompat.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW | MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
    MenuItemCompat.setActionView(item, sv);
    sv.setOnQueryTextListener(this);
    sv.setIconifiedByDefault(false);
    sv.setOnSearchClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {}
        });

    MenuItemCompat.setOnActionExpandListener(
        item,
        new MenuItemCompat.OnActionExpandListener() {
          @Override
          public boolean onMenuItemActionCollapse(MenuItem item) {
            // Do something when collapsed
            return true; // Return true to collapse action view
          }

          @Override
          public boolean onMenuItemActionExpand(MenuItem item) {
            // Do something when expanded
            return true; // Return true to expand action view
          }
        });

    super.onCreateOptionsMenu(menu, inflater);
  }
예제 #18
0
  void initializeSettingsButton(Menu OptionsMenu) {
    // Add refresh in Action Bar
    MenuItem settingsItem =
        OptionsMenu.add(Menu.NONE, Menu.NONE, Menu.NONE, getString(R.string.settings));

    // Set up the view
    settingsItem.setIcon(R.drawable.ic_settings);

    // Specify the show flags
    MenuItemCompat.setShowAsAction(settingsItem, MenuItem.SHOW_AS_ACTION_ALWAYS);

    // On click, go to Settings
    settingsItem.setOnMenuItemClickListener(
        new MenuItem.OnMenuItemClickListener() {
          @Override
          public boolean onMenuItemClick(MenuItem item) {
            // Start settings activity
            goToSettings(false);

            // Consume event
            return true;
          }
        });
  }
예제 #19
0
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
   this.setAsHomeMenuItem = menu.add(R.string.set_as_home);
   MenuItemCompat.setShowAsAction(this.setAsHomeMenuItem, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
   return true;
 }