j2me - Is it possible to customize a List so that it accept multi-line items?

83 Views Asked by At

Is there any way to force a List to show its items like this??

enter image description here

This works fine in the emulator , but when I run the app in the device(Nokia 208) every item is shown in a single line in which only a tiny part of the string is shown and the rest is completed with ellipsis.

This is how I create my list:

public class scrSearchResults extends List {

    private final Product[] mData;

    public static scrSearchResults create(Product[] data) {

        int i = 0;
        for (; i < data.length; i++) {
            if (data[i] == null) {
                break;
            }
        }
        String[] names = new String[i];
        for (int j = 0; j < i; j++) {
            names[j] = "[" + data[j].id + "] \n" + data[j].name + " \n" + data[j].price;
        }
        return new scrSearchResults(names, data);

    }

    protected scrSearchResults(String names[], Product[] data) {
        super("Filter Results", IMPLICIT, names, null);
        this.mData = data;
    }

    public Product getSelectedObject() {
        return mData[this.getSelectedIndex()];
    }
}

As you can see I'm trying to force a newline using '\n', but it only works on the emulator.

Do you know if it is possible to do this without using a library like LWUIT? I might use lwuit in the near future , but as for now I'm very short of time and I really need to find a way to do this so that once the first version of the project is accepted we can work on a second version in which I will definitely use lwuit. But if I fail now , there won't be any version to improve.

Please any help would be very much appreciated Thanks in advance.

0

There are 0 best solutions below