×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jun 2014
    Posts
    7

    How to create a multiline List in J2ME

    Hi.

    Is there any way to force a Nokia 208 to display a List like this??



    This works fine in the emulator , but when I run the app in the device every item is shown in a single line.

    Do you know if it is possible to do this without using a library like LWUIT?

    Thanks in advance.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,764

    Re: How to create a multiline List in J2ME

    You can check http://developer.nokia.com/community...ist_in_Java_ME for some customized List implementation with LCDUI (http://developer.nokia.com/community...Category:LCDUI is the category page you may find useful)

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to create a multiline List in J2ME

    You can also refer to my wiki article - http://developer.nokia.com/community...Menu_on_Canvas
    If you wish to make a List Menu on the low level Canvas screen directly.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    Jun 2014
    Posts
    12

    Re: How to create a multiline List in J2ME

    Is it canvas the only solution???

  5. #5
    Registered User
    Join Date
    Jun 2014
    Posts
    7

    Re: How to create a multiline List in J2ME

    So the only solution is to use Canvas ?? Not being able to have multiline items in a List or using the whole screen make me think in giving lwuit a go.
    The problem is that the mobile that I'm using (Nokia 208) wouldn't let me install a jar with more than 700 KB (the especifications say that the maximun jar size is 2MB) and based on the little I've seen of Lwuit , it is kind of big and to be honest I don't know what to do. Plain lcdui is lighter but in that nokia the interfaces are too big and I can't even control the order in which the commands are displayed (besides the others problems I mentioned ealier)

  6. #6
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: How to create a multiline List in J2ME

    Use LWUIT, it works for devices with 2MB JAR size limit. Refer to below link for more info on using LWUIT List... (LWUIT works on Canvas directly)
    http://developer.nokia.com/community...ing_LWUIT_List
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  7. #7
    Registered User
    Join Date
    Jun 2014
    Posts
    7

    Re: How to create a multiline List in J2ME

    Please, is it really not possible to force a List to understand a newline character??
    Please champions, there's gotta be someone among all of you that knows a workaround for this The viability of my project depends on being able to display a multi-line List. If I can do in the next version I could use lwuit, but if I can't the project is likely to be cancelled.

    At the moments this is the code I use create my lists

    Code:
    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 extend the List class so that I can have a List with an associated array of objects and then when an object is selected instead of returning a simple index , I return the correponding object for the selectedIndex.
    Everything works fine, except for the fact the newline character only works on the emulator but not on the nokia device in which every item is shown as a single line with only a tiny part of the string and the rest is completed with ellipsis

    Please any help would be very much appreciated
    Thanks in advance.
    Last edited by eddy17; 2014-07-05 at 16:02.

  8. #8
    Registered User
    Join Date
    Jun 2014
    Posts
    7

    Smile Re: How to create a multiline List in J2ME

    Thank God I remembered this constant: TEXT_WRAP_ON
    I didn't use it before because the book I read said that this might work only on some devices and so I assumed it as a 'don't-use-it' thing. But desperate as I was I gave it a go and it worked

    So this is how I set my Lists now:

    Code:
        protected scrSearchResults(String names[], Product[] data) {
            super("Filter Results", IMPLICIT, names, null);
             super.setFitPolicy(TEXT_WRAP_ON);
            this.mData = data;
        }
    Thank you guys and please if you know something about setFitPolicy that you think I should know, please let me know.

Similar Threads

  1. How to create multiline query dialog box
    By nishantanindya in forum Symbian User Interface
    Replies: 1
    Last Post: 2012-03-14, 13:15
  2. List Query multiline
    By niff111 in forum Symbian
    Replies: 0
    Last Post: 2009-03-11, 23:48
  3. list with multiline text items
    By zbotto in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-11-05, 03:55
  4. How to create Drop down list in J2ME
    By jas127 in forum Mobile Java General
    Replies: 1
    Last Post: 2007-10-24, 22:55

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×