Creating a list style button set

A list style button set is a set of ListStyleButtonField objects that are drawn with a visual style that indicates a logical grouping. The corners of the top field and bottom field in the set are rounded to create a strong association between the fields. You can use the ListStyleButtonSet class to display any number of ListStyleButtonField objects.

You might use a ListStyleButtonSet object to display a set of items that are closely related, such as related options in an options screen in your application.

Create a list style button set

  1. Import the required classes and interfaces.
    import com.blackberry.toolkit.ui.component.ListStyleButtonField;
    import com.blackberry.toolkit.ui.container.ListStyleButtonSet;
    import net.rim.device.api.system.Bitmap;
  2. Create new Bitmap objects to represent the left and right icons for each ListStyleButtonField object on your screen. Invoke the static Bitmap.getBitmapResource() to retrieve a Bitmap object from an image resource file. In this task, each ListStyleButtonField object uses the same icon on the right side of the button and no icon on the left side of the button.
    Bitmap buttonRight = Bitmap.getBitmapResource( "rightImage.png" );
  3. Create a new ListStyleButtonSet object to contain the buttons.
    ListStyleButtonSet buttonSet = new ListStyleButtonSet();
  4. Create new ListStyleButtonField objects to represent the buttons. Specify the appropriate Bitmap objects in the ListStyleButtonField constructor.
    ListStyleButtonField aboutButton = new ListStyleButtonField( "About", buttonRight );
    ListStyleButtonField ownerButton = new ListStyleButtonField( "Owner", buttonRight );
    ListStyleButtonField statusButton = new ListStyleButtonField( "Status", buttonRight );
  5. Add the ListStyleButtonField objects to the ListStyleButtonSet.
    buttonSet.add( aboutButton );
    buttonSet.add( ownerButton );
    buttonSet.add( statusButton );
  6. Add the ListStyleButtonSet object to the screen.
    add( buttonSet );

Was this information helpful? Send us your comments.