Example usage for android.view SubMenu clearHeader

List of usage examples for android.view SubMenu clearHeader

Introduction

In this page you can find the example usage for android.view SubMenu clearHeader.

Prototype

public void clearHeader();

Source Link

Document

Clears the header of the submenu.

Usage

From source file:com.andrew.apollo.utils.MusicUtils.java

/**
 * Creates a sub menu used to add items to a new playlist or an existing
 * one./*from   w ww  . ja v  a  2  s.  co  m*/
 *
 * @param context The {@link Context} to use.
 * @param groupId The group Id of the menu.
 * @param subMenu The {@link SubMenu} to add to.
 * @param showFavorites True if we should show the option to add to the
 *            Favorites cache.
 */
public static void makePlaylistMenu(final Context context, final int groupId, final SubMenu subMenu,
        final boolean showFavorites) {
    //        subMenu.clear();
    subMenu.clearHeader();
    if (showFavorites) {
        subMenu.add(groupId, FragmentMenuItems.ADD_TO_FAVORITES, Menu.NONE, R.string.add_to_favorites);
    }
    subMenu.add(groupId, FragmentMenuItems.NEW_PLAYLIST, Menu.NONE, R.string.new_empty_playlist);
    Cursor cursor = PlaylistLoader.makePlaylistCursor(context);
    if (cursor != null && cursor.getCount() > 0 && cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
            final Intent intent = new Intent();
            String name = cursor.getString(1);
            //LOG.info("makePlaylistMenu - add ["+name+"]");
            if (name != null) {
                intent.putExtra("playlist", getIdForPlaylist(context, name));
                subMenu.add(groupId, FragmentMenuItems.PLAYLIST_SELECTED, Menu.NONE, name).setIntent(intent);
            }
            cursor.moveToNext();
        }
    }
    if (cursor != null) {
        cursor.close();
    }
}