×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    Smile Choicegroup.popup

    hi, i was wondering how to set the focus for a selected index/item in a choicegroup.popup when the user goes back to the previous canvas?

    eg.

    sizeChoice = new ChoiceGroup("Size:", Choice.POPUP);
    sizeChoice.append("Small", null);
    sizeChoice.append("Medium",null);
    sizeChoice.append("Large", null);
    form.append(sizeChoice);


    the user have selected anything yet, thus the "small" will be focused.

    sizeChoice.append("Medium",null); <--- this is selected.

    After that the user selects "medium" and goes to the next canvas but when he return to the previous canvas, "small" is selected instead of "medium".

    so the problem is how do i set focus on "medium" when the user goes back to the previous canvas.

    thanks =)

  2. #2
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: Choicegroup.popup

    Hi,

    Try to use setSelectedIndex Method in the choiceGroup that will probably solve your problem.
    Sunil
    Mobile Application Developer

  3. #3
    Registered User
    Join Date
    Nov 2008
    Posts
    9

    Re: Choicegroup.popup

    sizeChoice.setSelectedIndex(1, true);
    is this how you do it?, i tried, but none is selected.


    Edit: i solved it, thanks a lot. it was indeed using .setSelectedIndex, just wrong if/else statements
    Last edited by nabenabu; 2008-11-20 at 05:40.

  4. #4
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: Choicegroup.popup

    Hi,

    Try this

    int defaultindex = sizeChoice.append("Small", null);
    sizeChoice.append("Medium", null);
    sizeChoice.append("Large", null);

    sizeChoice.setSelectedIndex(defaultindex, true);

    This will set your default selection as Small. After that to change that you can use getSelectedIndex too. Read the using choiceGroup properly and you will be able to do this coz this is not at all difficult.
    Sunil
    Mobile Application Developer

  5. #5
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    65

    Re: Choicegroup.popup

    Are you creating the screen with the Choicegroup again?? if so don't do it just set the screen with the Choice group to the current when you get back. You should pass the Form instance to the next screen.
    Also setSelectedIndex will work if you save the selection done previously in the RMS or as a global static variable.
    Thanks and Regrads
    Pradeepcg

Posting Permissions

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