My answer will be along the lines of jitter's response. The general idea for the kind of customizations that you want is to override the default behavior of the basic components.
Suppose, the choices that you want to display can be encapsulated by a class named Choice
declared as follows:
private class Choice
{
public Bitmap image;
public String label;
public Choice(String name)
{
this.image = Bitmap.getBitmapResource(name + ".png");
this.label = name;
}
public String toString()
{
return this.label;
}
}
then you can declare an ObjectListField
instance as:
ObjectChoiceField choice = new ObjectChoiceField()
{
protected void paint(Graphics graphics)
{
// Get the current selected Choice
Choice item = (Choice) this.getChoice(getSelectedIndex());
int xOffset = 5; // 5 px padding on the left
graphics.drawBitmap(xOffset, 0,
item.image.getWidth(),
item.image.getHeight(),
item.image,
0, 0);
// Add text after the image and 10px padding.
xOffset += item.image.getWidth() + 10;
graphics.drawText(item.label, xOfffset, 0);
}
};
set your choice items as:
choice.setChoices(new Choice[]{ new Choice("choice 1"), new Choice("choice 2")});
and then add it to your Screen
(or FieldManager
of your choice) using:
add(choice);
I have not been able to override the actual selection pop-up menu items. This seems to call the toString()
method of your choice items. That is why I have overriden the default implementation of toString()
in the Choice
class so that we can display logical names in that pop-up.