I used the following code to display a rich list.
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.component.table.*;
public class RichListDemo extends UiApplication
{
public static void main(String[] args)
{
RichListDemo theApp = new RichListDemo();
theApp.enterEventDispatcher();
}
public RichListDemo()
{
pushScreen(new RichListScreen());
}
private static class RichListScreen extends MainScreen
{
public RichListScreen()
{
super(Manager.NO_VERTICAL_SCROLL);
setTitle("Rich List Demo");
add(new LabelField("BlackBerry Devices", LabelField.FIELD_HCENTER));
add(new SeparatorField());
Manager mainManager = getMainManager();
RichList list = new RichList(mainManager, true, 2, 1);
Bitmap bitmap1 = Bitmap.getBitmapResource("9500.png");
Bitmap bitmap2 = Bitmap.getBitmapResource("9000.png");
list.add(new Object[] {bitmap1, "Device 1", "BlackBerry Smartphone 9500", "Description of Device 1."});
list.add(new Object[] {bitmap2, "Device 2", "BlackBerry Smartphome 9000", "Description of Device 2."});
}
}
}
How to implement click event in the Rich List ?. When i click the List, i want to show a dilog box. Is it possible ?.
You cannot determine the selected row in a RichList
. You can use a TableView
instead of RichList
if you want to have click functionality . RichList
should be used for read only items you want to display. If you want to capture input and/or allow a user to make a selection then a TableView
should be used.
You can use this link to create a table view and add clickable fields in the row