×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    76

    two text fields in a single row

    I can't figure out how to have two text fields in a single row.

    Item item = new TextField(null, "59", 2, TextField.NUMERIC);
    item.setLayout(Item.LAYOUT_SHRINK | Item.LAYOUT_2);
    append(item);
    item = new TextField(null, "12.234", 6, TextField.DECIMAL);
    item.setLayout(Item.LAYOUT_SHRINK | Item.LAYOUT_2);
    append(item);

    Works fine in emulator, but not in real 6230i.

    Thanks in advance for any hint!

  2. #2
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: two text fields in a single row

    Hi, hnipak!

    The Form class which you are using simply puts GUI items each one after another, from the top to bottom, and as far as I know, on the standard Form you cannot affect on how your components are presented on the screen, because Java decides it by itself, according to screen sizes, type of the GUI component, look & feel styles, etc. (as the LCDUI specification says).

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    76

    Re: two text fields in a single row

    Hi,

    well it appears so, but then I do not understand what the new (in MIDP 2) layout directives are good for, and why even Nokia itself advertises them in eg. "MIDP 2.0 Introduction 1.1" document.

    There must be something I have overlooked...

    Thanks.

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    USA, CA
    Posts
    7,191

    Re: two text fields in a single row

    Apparently the 6230i implementation considers the row to be full after the first TextField.
    "If the Item is too wide to fit in the space remaining on the row, the row is considered to be full, a new row is added beneath this one, and the Item is laid out on this new row."

    Have you tried with any other phone, with a little bigger screen?

    Hartti

  5. #5
    Registered User
    Join Date
    May 2005
    Posts
    76

    Re: two text fields in a single row

    Yes that would be logical, but since the first text field has no label and editable part has maximum size limit set to 2 characters (how many pixels can a 2-char string could be wide? 20-30px max?), the second 6 characters (100-120px max?), I doubt that having a display wider than 208px would help anyway... there is something wrong on principle I guess.

    I have not tested it in any other phone yet, though.

    Thanks.

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: two text fields in a single row

    hi guys,

    I've read FN docs about S60/S40 implementations yesterday and they DO mention "multiple items" in "single row" (either locked or unlocked and with Item.LAYOUT_2 used) but NOT for TextFields, which are always seem to take Form width by default probably,
    Nokia docs state about other items somethin' like:
    There can be multiple items in a single row if the LAYOUT_2 directive is used.
    but not when describing TextField,
    I could be wrong about that though having no S40 device with MIPD2.0 yet,

    regards,
    Peter

  7. #7
    Registered User
    Join Date
    May 2005
    Posts
    76

    Re: two text fields in a single row

    I would assume that "items" here mean instances of Item, and TextField is instanceof Item. And by the way, two text fields is just what is used in Nokia's "MIDP Introduction
    1.1" to demonstrate LAYOUT_2.

  8. #8
    Regular Contributor
    Join Date
    Aug 2006
    Location
    Rawalpindi, Pakistan
    Posts
    486

    Re: two text fields in a single row

    So far it is not possible to put two textfields in a single row in series 60 i have tested it. dont know about other series.
    Regards
    Nouman

  9. #9
    Regular Contributor
    Join Date
    Aug 2006
    Posts
    307

    Re: two text fields in a single row

    Hi, hnipak!

    If you really need to have two text fields on a single row, then have you ever considered a solution based on the CustomItem? I mean you can implement a customized item so that it will represent two text fields on the same row, and you will use it even on small screens. It is actually not an easy thing to implement, but, anyway, here you can take a look at a very simple example:

    Using Custom Items in MIDP 2.0: http://developers.sun.com/techtopics...ps/customitem/

    Or simply ask Mr. Google
    Last edited by axs; 2006-09-19 at 11:43.

  10. #10
    Registered User
    Join Date
    May 2005
    Posts
    76

    Re: two text fields in a single row

    Hi axs,

    you are right. I've been thinking of subclassing CustomItem, too.

    Regards, h.

  11. #11
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: two text fields in a single row

    Quote Originally Posted by hnipak
    And by the way, two text fields is just what is used in Nokia's "MIDP Introduction 1.1" to demonstrate LAYOUT_2.
    that's opposite from what is stated in book "Developing scalable S40 seriers applicaitons" - where they noted that items like TextField and Gauge (and others listed) always are rendered in single row only no matter of layout settings,
    I think we are stick with custom items,

    regards,
    Peter

  12. #12
    Registered User
    Join Date
    Sep 2006
    Posts
    27

    Re: two text fields in a single row

    In the document entitled 'S60 2nd Edition: Specification (January 20, 2004)' it reads:

    2.1.10.3.12.1 Row breaks

    In MIDP 1.0 implementations, ChoiceGroup, DateField, Gauge, and TextField are presented in their own lines. This is also true in MIDP 2.0 if ChoiceGroup, DateField, Gauge, or TextField does not have the LAYOUT_2 directive set (for backwards compatibility with MIDP 1.0). In MIDP 2.0, the LAYOUT_2 directive is ignored in CustomItem, StringItem, and Spacer.

    In MIDP 2.0 implementations in UI styles with two-way navigation, row breaks will occur as in MIDP 1.0, even when LAYOUT_2 is set. This is done for focus traversal reasons. Focus traversal need not go sideways.
    In MIDP 2.0 implementations in UI styles with four-way navigation, Gauge is presented in a separate line regardless of whether or not LAYOUT_2 is set. This is also done for focus traversal reasons. In Gauge, the left and right keys are needed for changing the gauge value since four-way styles will have inline editing.

    Otherwise, in MIDP 2.0 implementations the row breaks happen as defined by the MIDP 2.0 Specification [MIDP2.0].

    ----------------

    But in a later document, MIDP 2.0: Introduction (December 21, 2004), Nokia do a u-turn and say:

    In MIDP 1.0, the typical output would look similar to Figure 1. With MIDP 2.0, using Layout directives, we can make a request to shrink each item, allowing both fields to fit on the same row (Figure 2). Notice that several fields can’t fit in the same row in Series 40 and Series 60 devices, but in Series 80 devices they can.

    -----------------

    So it was in the initial spec for S60 2nd Edition but never got implemented, nor is it in the 3rd Edition. Handy! CustomItems it is then. This is all well and good unless you wanted to use the predictive text features of TextField!

Similar Threads

  1. Replies: 6
    Last Post: 2005-05-17, 10:07
  2. Replies: 0
    Last Post: 2004-11-24, 18:49
  3. 3 fields in 1 row
    By youngboyguy in forum Mobile Java Media (Graphics & Sounds)
    Replies: 5
    Last Post: 2004-08-12, 10:15
  4. 3 fields in 1 row
    By youngboyguy in forum Mobile Java General
    Replies: 0
    Last Post: 2004-07-07, 07:21
  5. Editor & text fields
    By basarim in forum Symbian
    Replies: 0
    Last Post: 2004-02-19, 09:20

Posting Permissions

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