コード例 #1
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {

    super.onCreateOptionsMenu(menu);
    // menu.add(Menu.NONE, SEARCH_ID, Menu.NONE,
    // "Search").setIcon(android.R.drawable.ic_menu_search).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(Menu.NONE, REFRESH_MORE, Menu.NONE, "Refresh")
        .setIcon(android.R.drawable.ic_popup_sync)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(Menu.NONE, CONTACT_US, Menu.NONE, "Contact Us")
        .setIcon(android.R.drawable.ic_menu_info_details)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(Menu.NONE, REQUEST_CAT, Menu.NONE, "Request Category")
        .setIcon(android.R.drawable.ic_menu_upload)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    return true;
  }
コード例 #2
0
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    this.optionsMenu = menu;
    MenuItem item;

    menu.add(0, 1, 0, getString(R.string.create_page))
        .setIcon(R.drawable.add)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    //		menu.add(0, 2, 0, getString(R.string.search)).setIcon(R.drawable.search)
    //		.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    menu.add(0, 0, 0, getString(R.string.write))
        .setIcon(R.drawable.write)
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    menu.add(0, 100, 0, getString(R.string.change_user))
        .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    menu.add(0, 200, 0, getString(R.string.invite)).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

    menu.findItem(0).setVisible(fragment_position == 1 || fragment_position != 2);
    menu.findItem(1).setVisible(fragment_position == 3);

    // User change
    menu.findItem(100).setVisible(Global.getSetting("default_user", "Y").matches("N"));

    // Invite
    menu.findItem(200).setVisible(fragment_position == 2);

    // item = menu.add(0, 1, 0, R.string.Main_MenuAddBookmark);
    // item.setIcon(R.drawable.ic_menu_add_bookmark);

    return true;
  }