Search in sources :

Example 11 with SubMenu

use of com.actionbarsherlock.view.SubMenu in project little-bear-dictionary by daimajia.

the class ShareActionProvider method onPrepareSubMenu.

/**
     * {@inheritDoc}
     */
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();
    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);
    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
    }
    if (collapsedActivityCount < expandedActivityCount) {
        // Add a sub-menu for showing all activities as a list item.
        SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, collapsedActivityCount, mContext.getString(R.string.abs__activity_chooser_view_see_all));
        for (int i = 0; i < expandedActivityCount; i++) {
            ResolveInfo activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) SubMenu(com.actionbarsherlock.view.SubMenu)

Example 12 with SubMenu

use of com.actionbarsherlock.view.SubMenu in project cw-omnibus by commonsguy.

the class ShareActionProvider method onPrepareSubMenu.

/**
     * {@inheritDoc}
     */
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();
    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);
    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
    }
    if (collapsedActivityCount < expandedActivityCount) {
        // Add a sub-menu for showing all activities as a list item.
        SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, collapsedActivityCount, mContext.getString(R.string.abs__activity_chooser_view_see_all));
        for (int i = 0; i < expandedActivityCount; i++) {
            ResolveInfo activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) SubMenu(com.actionbarsherlock.view.SubMenu)

Example 13 with SubMenu

use of com.actionbarsherlock.view.SubMenu in project Libraries-for-Android-Developers by eoecn.

the class MenuWrapper method addInternal.

private SubMenu addInternal(android.view.SubMenu nativeSubMenu) {
    SubMenu subMenu = new SubMenuWrapper(nativeSubMenu);
    android.view.MenuItem nativeItem = nativeSubMenu.getItem();
    MenuItem item = subMenu.getItem();
    mNativeMap.put(nativeItem, item);
    return subMenu;
}
Also used : SubMenu(com.actionbarsherlock.view.SubMenu) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 14 with SubMenu

use of com.actionbarsherlock.view.SubMenu in project Libraries-for-Android-Developers by eoecn.

the class ShareActionProvider method onPrepareSubMenu.

/**
     * {@inheritDoc}
     */
@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    // Clear since the order of items may change.
    subMenu.clear();
    ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
    PackageManager packageManager = mContext.getPackageManager();
    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, mMaxShownActivityCount);
    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
        ResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
    }
    if (collapsedActivityCount < expandedActivityCount) {
        // Add a sub-menu for showing all activities as a list item.
        SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, collapsedActivityCount, mContext.getString(R.string.abs__activity_chooser_view_see_all));
        for (int i = 0; i < expandedActivityCount; i++) {
            ResolveInfo activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.loadLabel(packageManager)).setIcon(activity.loadIcon(packageManager)).setOnMenuItemClickListener(mOnMenuItemClickListener);
        }
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) SubMenu(com.actionbarsherlock.view.SubMenu)

Example 15 with SubMenu

use of com.actionbarsherlock.view.SubMenu in project ActionBarSherlock by JakeWharton.

the class SubMenus method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    SubMenu subMenu1 = menu.addSubMenu("Action Item");
    subMenu1.add("Sample");
    subMenu1.add("Menu");
    subMenu1.add("Items");
    MenuItem subMenu1Item = subMenu1.getItem();
    subMenu1Item.setIcon(R.drawable.ic_title_share_default);
    subMenu1Item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
    SubMenu subMenu2 = menu.addSubMenu("Overflow Item");
    subMenu2.add("These");
    subMenu2.add("Are");
    subMenu2.add("Sample");
    subMenu2.add("Items");
    MenuItem subMenu2Item = subMenu2.getItem();
    subMenu2Item.setIcon(R.drawable.ic_compose);
    return super.onCreateOptionsMenu(menu);
}
Also used : SubMenu(com.actionbarsherlock.view.SubMenu) MenuItem(com.actionbarsherlock.view.MenuItem)

Aggregations

SubMenu (com.actionbarsherlock.view.SubMenu)21 MenuItem (com.actionbarsherlock.view.MenuItem)9 PackageManager (android.content.pm.PackageManager)7 ResolveInfo (android.content.pm.ResolveInfo)7