Search in sources :

Example 21 with SubMenu

use of android.view.SubMenu in project SR-Tracker-for-Overwatch by Rexios80.

the class PlacementsActivity method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.placements_actionbar, menu);
    MenuItem seasonList = menu.findItem(R.id.seasons);
    SubMenu subMenu = seasonList.getSubMenu();
    // Get seasons list from database
    mDbHelper = new DatabaseHelper(getApplicationContext());
    db = mDbHelper.getWritableDatabase();
    String[] projection = { DatabaseContract.Database._ID, DatabaseContract.Database.COLUMN_NAME_SEASON };
    String sortOrder = DatabaseContract.Database.COLUMN_NAME_SEASON + " ASC";
    Cursor cursor = db.query(DatabaseContract.Database.SEASONS_TABLE_NAME, projection, null, null, null, null, sortOrder);
    ArrayList<Integer> seasons = new ArrayList<>();
    while (cursor.moveToNext()) {
        seasons.add(cursor.getInt(cursor.getColumnIndexOrThrow(DatabaseContract.Database.COLUMN_NAME_SEASON)));
    }
    cursor.close();
    // Add seasons to subMenu
    if (seasons.size() <= 1) {
        MenuItem item = menu.findItem(R.id.seasons);
        item.setVisible(false);
    }
    for (int i = 0; i < seasons.size(); i++) {
        subMenu.add(0, i, Menu.NONE, "Season " + seasons.get(i));
    }
    return true;
}
Also used : MenuInflater(android.view.MenuInflater) ArrayList(java.util.ArrayList) MenuItem(android.view.MenuItem) SubMenu(android.view.SubMenu) Cursor(android.database.Cursor)

Example 22 with SubMenu

use of android.view.SubMenu in project android_frameworks_base by ResurrectionRemix.

the class ListContextMenu method onCreateOptionsMenu.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuItem item = menu.add(0, 0, 0, "Really long menu item name");
    item.setTitleCondensed("Long name");
    item.setIcon(R.drawable.black_square);
    SubMenu sm = menu.addSubMenu(0, 0, 0, "The 2nd item, a sub menu").setIcon(R.drawable.black_square_stretchable);
    item = sm.getItem();
    item.setTitleCondensed("Sub menu");
    sm.add(1, 0, 0, "Subitem 1");
    sm.add(1, 0, 0, "Subitem 2");
    sm.add(1, 0, 0, "Subitem 3");
    sm.setGroupCheckable(1, true, true);
    menu.add(0, 0, 0, "Item 3");
    menu.add(0, 0, 0, "Item 4");
    menu.add(0, 0, 0, "Item 5");
    menu.add(0, 0, 0, "Item 6");
    menu.add(0, 0, 0, "Item 7");
    menu.add(0, 0, 0, "Item 8");
    menu.add(0, 0, 0, "Item 9");
    sm = menu.addSubMenu(0, 0, 0, "Item 10 SM");
    sm.add(0, 0, 0, "Subitem 1");
    sm.add(0, 0, 0, "Subitem 2");
    sm.add(0, 0, 0, "Subitem 3");
    sm.add(0, 0, 0, "Subitem 4");
    sm.add(0, 0, 0, "Subitem 5");
    sm.add(0, 0, 0, "Subitem 6");
    sm.add(0, 0, 0, "Subitem 7");
    sm.add(0, 0, 0, "Subitem 8");
    return true;
}
Also used : MenuItem(android.view.MenuItem) SubMenu(android.view.SubMenu)

Example 23 with SubMenu

use of android.view.SubMenu in project android_frameworks_base by DirtyUnicorns.

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.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(android.view.SubMenu)

Example 24 with SubMenu

use of android.view.SubMenu in project AisenWeiBo by wangdan.

the class PublishStatusFragment method onCreateOptionsMenu.

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.menu_publish, menu);
    // 添加分组
    if (AppContext.getAccount().getGroups() == null || AppContext.getAccount().getGroups().getLists().size() == 0) {
    } else {
        SubMenu subMenu = menu.addSubMenu(R.id.publish, 333, 2, GlobalContext.getInstance().getResources().getString(R.string.group_selected_visiable));
        for (int i = 0; i < AppContext.getAccount().getGroups().getLists().size(); i++) {
            Group group = AppContext.getAccount().getGroups().getLists().get(i);
            subMenu.add(100, i, i, group.getName());
        }
    }
}
Also used : Group(org.aisen.weibo.sina.sinasdk.bean.Group) SubMenu(android.view.SubMenu)

Example 25 with SubMenu

use of android.view.SubMenu in project android_frameworks_base by crdroidandroid.

the class ListContextMenu method onCreateContextMenu.

public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    String text = ((TextView) info.targetView).getText().toString();
    if (text.contains("[0]")) {
        menu.setHeaderTitle("This is a test of the title and the icon").setHeaderIcon(android.R.drawable.sym_def_app_icon);
    } else if (text.contains("[1]")) {
        menu.setHeaderTitle("This is a test of just the title");
    } else {
        TextView textView = new TextView(this);
        textView.setText("This is a test of a custom View");
        menu.setHeaderView(textView);
    }
    menu.add(0, 0, 0, "Test 1");
    SubMenu sm = menu.addSubMenu(0, 0, 0, "Test 1.5 SM");
    sm.add(0, 0, 0, "CM Subitem 1");
    sm.add(0, 0, 0, "CM Subitem 2");
    sm.add(0, 0, 0, "CM Subitem 3");
    menu.add(0, 0, 0, "Test 2");
    menu.add(0, 0, 0, "Test 3");
    menu.add(0, 0, 0, "Test 4");
    menu.add(0, 0, 0, "Test 5");
    menu.add(0, 0, 0, "Test 6");
    menu.add(0, 0, 0, "Test 7");
    menu.add(0, 0, 0, "Test 8");
    menu.add(0, 0, 0, "Test 9");
    menu.add(0, 0, 0, "Test 10");
    menu.add(0, 0, 0, "Test 11");
    menu.add(0, 0, 0, "Test 12");
    menu.add(0, 0, 0, "Test 13");
    menu.add(0, 0, 0, "Test 14");
    menu.add(0, 0, 0, "Test 15");
    menu.add(0, 0, 0, "Test 16");
    menu.add(0, 0, 0, "Test 17");
    menu.add(0, 0, 0, "Test 18");
    menu.add(0, 0, 0, "Test 19");
    menu.add(0, 0, 0, "Test 20");
    menu.add(0, 0, 0, "Test 21");
    menu.add(0, 0, 0, "Test 22");
    menu.add(0, 0, 0, "Test 23");
    menu.add(0, 0, 0, "Test 24");
}
Also used : AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) SubMenu(android.view.SubMenu)

Aggregations

SubMenu (android.view.SubMenu)80 MenuItem (android.view.MenuItem)38 View (android.view.View)11 LayoutInflater (android.view.LayoutInflater)10 PackageManager (android.content.pm.PackageManager)9 Bundle (android.os.Bundle)9 Nullable (android.support.annotation.Nullable)9 ViewGroup (android.view.ViewGroup)9 R (com.simplecity.amp_library.R)9 UpgradeDialog (com.simplecity.amp_library.ui.dialog.UpgradeDialog)9 SelectableViewModel (com.simplecity.amp_library.ui.modelviews.SelectableViewModel)9 ContextualToolbar (com.simplecity.amp_library.ui.views.ContextualToolbar)9 ContextualToolbarHelper (com.simplecity.amp_library.utils.ContextualToolbarHelper)9 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)9 PlaylistUtils (com.simplecity.amp_library.utils.PlaylistUtils)9 ViewModel (com.simplecityapps.recycler_adapter.model.ViewModel)9 Disposable (io.reactivex.disposables.Disposable)9 ResolveInfo (android.content.pm.ResolveInfo)8 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)8 RecyclerListener (com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener)8