O'Reilly logo

BlackBerry Java Application Development by Bill Foust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - creating a ListField

  1. The first thing that you need to do is change the class declaration again to implement the callback interface. Replace the class declaration with the following list.
    public class FieldSamplerScreen extends MainScreen implements FieldChangeListener, ListFieldCallback
    
  2. Next, you need to add a data member to the class to hold the items of your list.
    protected String listMembers[] = {"Item1","Item2","Item3"};
    
  3. Next, you need to implement the methods of the callback. Add the following methods to the FieldSamplerMainScreen class.
    public void drawListRow(ListField list, Graphics g, int index, int y,int width) { g.drawText( listMembers[index], 0, y, 0, 50 ); switch (index) { case 0: g.setColor(Color.BLUE); g.setFont(Font.getDefault().derive(Font.BOLD)); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required