Example usage for android.view MenuItem setTitleCondensed

List of usage examples for android.view MenuItem setTitleCondensed

Introduction

In this page you can find the example usage for android.view MenuItem setTitleCondensed.

Prototype

public MenuItem setTitleCondensed(CharSequence title);

Source Link

Document

Change the condensed title associated with this item.

Usage

From source file:com.meetingninja.csse.agenda.AgendaActivity.java

@Override
public boolean onPrepareOptionsMenu(final Menu menu) {
    final MenuItem collapsibleMenu = menu.findItem(R.id.collapsible_menu_item);
    if (collapsible) {
        collapsibleMenu.setTitle(R.string.collapsible_menu_disable);
        collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_disable));
        collapsibleMenu.setChecked(collapsible);
    } else {//from w  w w . j a  v a 2  s .  com
        collapsibleMenu.setTitle(R.string.collapsible_menu_enable);
        collapsibleMenu.setTitleCondensed(getResources().getString(R.string.collapsible_condensed_enable));
    }
    return super.onPrepareOptionsMenu(menu);
}

From source file:org.apache.cordova.plugins.Actionable.java

public void buildMenu() {
    for (Actionable act : mMenuItems.values()) {
        MenuItem mi = mMenu.add(Menu.NONE, Menu.NONE, act.getOrder(), act.getTitle());

        mi.setTitleCondensed(act.getTitle());
        mi.setShowAsAction(act.getFlags());

        if (act.isDisabled()) {
            mi.setEnabled(false);//from  w ww.  j  a  v a  2  s . c om
        }

        if (act.getIcon() != null) {
            mi.setIcon(act.getIcon());
        }
    }
}

From source file:paulscode.android.mupen64plusae.game.GameActivity.java

private void UpdateControllerMenu(int menuItemId, boolean isPlugged, int playerNumber) {
    final MenuItem pakGroupItem = mGameSidebar.getMenu().findItem(R.id.menuItem_paks);

    if (mGameSidebar.getMenu().findItem(menuItemId) != null) {
        if (!isPlugged) {
            pakGroupItem.getSubMenu().removeItem(menuItemId);
        } else {//from   w  ww . j a  va  2 s. c  om
            final MenuItem playerItem = mGameSidebar.getMenu().findItem(menuItemId);
            playerItem.setTitleCondensed(
                    this.getString(mGlobalPrefs.getPakType(playerNumber).getResourceString()));
        }
    }
}

From source file:paulscode.android.mupen64plusae.game.GameActivity.java

public void setPakTypeFromPrompt(final int player) {
    //First get the prompt title
    final CharSequence title = GetPlayerTextFromId(player);
    final MenuItem playerMenuItem = GetPlayerMenuItemFromId(player);

    //Generate possible pak types
    final ArrayList<CharSequence> selections = new ArrayList<>();
    for (final PakType pakType : PakType.values()) {
        selections.add(this.getString(pakType.getResourceString()));
    }//  ww w.  j  a  v a2 s  .c  o m

    Prompt.promptListSelection(this, title, selections, new PromptIntegerListener() {
        @Override
        public void onDialogClosed(Integer value, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                mGlobalPrefs.putPakType(player, PakType.values()[value]);

                // Set the pak in the core
                NativeInput.setConfig(player - 1, true, PakType.values()[value].getNativeValue());

                //Update the menu
                playerMenuItem.setTitleCondensed(
                        GameActivity.this.getString(mGlobalPrefs.getPakType(player).getResourceString()));
                mGameSidebar.reload();
            }
        }
    });
}

From source file:paulscode.android.mupen64plusae.game.GameFragment.java

public void setPakTypeFromPrompt(final int player) {
    //First get the prompt title
    final CharSequence title = GetPlayerTextFromId(player);
    final MenuItem playerMenuItem = GetPlayerMenuItemFromId(player);

    //Generate possible pak types
    final ArrayList<CharSequence> selections = new ArrayList<>();
    for (final PakType pakType : PakType.values()) {
        selections.add(this.getString(pakType.getResourceString()));
    }/*w  w  w. j a v a2s.  c  o  m*/

    Prompt.promptListSelection(getActivity(), title, selections, new PromptIntegerListener() {
        @Override
        public void onDialogClosed(Integer value, int which) {
            if (which == DialogInterface.BUTTON_POSITIVE) {
                mGlobalPrefs.putPakType(player, PakType.values()[value]);

                // Set the pak in the core
                mCoreFragment.updateControllerConfig(player - 1, true,
                        PakType.values()[value].getNativeValue());

                //Update the menu
                playerMenuItem.setTitleCondensed(
                        GameFragment.this.getString(mGlobalPrefs.getPakType(player).getResourceString()));
                mGameSidebar.reload();
            }
        }
    });
}

From source file:com.native5.plugins.ActionBarPlugin.java

private boolean buildMenu(Menu menu, JSONArray definition, String menu_var) {
    // Sadly MenuItem.setIcon and SubMenu.setIcon have conficting return types (for chaining), thus this can't be done w/ generics :(
    class GetMenuItemIconTask extends AsyncTask<String, Void, Drawable> {
        public final MenuItem item;
        public Exception exception = null;

        GetMenuItemIconTask(MenuItem item) {
            this.item = item;
        }//from ww  w.  j  av a 2s.  c  om

        @Override
        protected Drawable doInBackground(String... uris) {
            return getDrawableForURI(uris[0]);
        }

        @Override
        protected void onPostExecute(Drawable icon) {
            if (icon != null) {
                item.setIcon(icon);
            }
        }
    }
    ;

    class GetSubMenuIconTask extends AsyncTask<String, Void, Drawable> {
        public final SubMenu item;
        public Exception exception = null;

        GetSubMenuIconTask(SubMenu item) {
            this.item = item;
        }

        @Override
        protected Drawable doInBackground(String... uris) {
            return getDrawableForURI(uris[0]);
        }

        @Override
        protected void onPostExecute(Drawable icon) {
            if (icon != null) {
                item.setIcon(icon);
            }
        }
    }
    ;

    try {
        for (int i = 0; i < definition.length(); ++i) {
            final JSONObject item_def = definition.getJSONObject(i);
            final String text = item_def.isNull("text") ? "" : item_def.getString("text");

            if (!item_def.has("items")) {
                MenuItem item = menu.add(0, i, i, text);
                item.setTitleCondensed(text);
                if (item_def.isNull("icon") == false) {
                    GetMenuItemIconTask task = new GetMenuItemIconTask(item);

                    synchronized (task) {
                        task.execute(item_def.getString("icon"));
                    }
                }

                // Default to MenuItem.SHOW_AS_ACTION_IF_ROOM, otherwise take user defined value.
                item.setShowAsAction(item_def.has("show") ? item_def.getInt("show")
                        : MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

                menu_callbacks.put(item,
                        "var item = " + menu_var + "[" + i + "]; if(item.click) item.click();");
            } else {
                SubMenu submenu = menu.addSubMenu(0, i, i, text);
                if (item_def.isNull("icon") == false) {
                    GetSubMenuIconTask task = new GetSubMenuIconTask(submenu);

                    synchronized (task) {
                        task.execute(item_def.getString("icon"));
                    }
                }

                // Set submenu header
                if (item_def.has("header")) {
                    JSONObject header = item_def.getJSONObject("header");

                    if (header.has("title")) {
                        submenu.setHeaderTitle(header.getString("title"));
                    }

                    if (header.has("icon")) {
                        submenu.setHeaderIcon(getDrawableForURI(header.getString("icon")));
                    }
                }

                // Build sub-menu
                buildMenu(submenu, item_def.getJSONArray("items"), menu_var + "[" + i + "].items");
            }
        }
    } catch (JSONException e) {
        return false;
    }

    return true;
}