Uriel Arvizu
Uriel Arvizu

Reputation: 1916

How to create a list of items where each row is composed of an image, text and a radio button?

I'm working with BlackBerry API 7.0 and I'm trying to display a list of countries, each row must display, in the following order, a country flag, the name of the country and a RadioButtonField to indicate the state of selection, something like this:

| -icon- -text- -radio button- |

I've been looking for an example of this kind of control, but haven't found a similar approach.

A RadioButtonGroup only hold RadioButtonFields so, as far as I understand, it isn't what I need.

I know there's the ListField but I haven't found an example of a Manager that implements the look & feel I'm trying to achieve, specially since I have to handle the selection of the RadioButtonField I'm not sure if adding a RadioButtonGroup with a single RadioButtonField to each row is the correct approach (specially since a RadioButtonGroup is not allowed on the Manager class) and if so, how can I handle the state of selection for a radio button on each row?.

What is the best way to implement the design I need? Can this be done with a RadioButtonGroup? Or is it possible to use a custom Manager class for this?

Upvotes: -1

Views: 44

Answers (1)

mr_lou
mr_lou

Reputation: 1920

I know that Blackberry has their own API's for various things - and I have absolutely no experience with any of those.

But the standard List class offers a way to use images in your list. You just have to create two arrays first. One with the string-elements and one with the image-elements.

String[] theStrings = {"1st item", "2nd item", "3rd item"};
try {
  image1 = Image.createImage("1stimage.png");
  image2 = Image.createImage("2ndimage.png");
  image3 = Image.createImage("3rdimage.png");
} catch (Exception e) {}
Image[] theImages = {image1, image2, image3};
int listType = List.IMPLICIT;
List myList = List("List title", listType, theStrings, theImages);

http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/javax/microedition/lcdui/List.html

(If this answer is completely wrong in relation to BlackBerry API 7.0, then the "java-me" tag should probably be removed from the question).

Upvotes: -1

Related Questions