×

Discussion Board

Results 1 to 6 of 6

Thread: Choice Group

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    Choice Group

    Hi all,

    I got some roblem in my application i need to create choice group for
    multiple choces
    call choicegroup XYZ Choices A, B, C, D
    at a time user has to select only 2 or 1 from 4 ie restricting the
    choces to only 2 or 1 choices it can be of any combination and i given
    values A=1, B=2, c=3 d=4 if user selects A and D the value for choice
    group becomes avg of 2 ie 2.5
    is that possible by using getselectedflags or any other clue
    please help me

    Kind Regards
    Jay

    for the present choice group i created is an exclusive one i need to use MULTIPLE choice group for this. ie id choice1 and 2 selected LTS value becomes 1.5 and 2 and 3 LTS=2.5.
    if(item==LTSimpleHairs)
    {

    int LTSimpleHairs1=LTSimpleHairs.getSelectedIndex();
    switch(LTSimpleHairs1)
    {
    case 0: LTS=1;
    System.out.println("Cordate Selected");
    break;
    case 1: LTS=2;
    System.out.println("Truncate Selected");
    break;
    case 2: LTS=3;
    System.out.println("Cuneate Selected");
    break;
    }
    }

  2. #2
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Choice Group

    Sorry buddy i dont understand what exactly you want.Can you pLease explain it more .Only the thing i understand is that you have created text box and you want that if you choose 1 and 3 it will give value 2 , if you choose 2 and 3 it will give value 2.5 .Tell me am i right so that i can help you
    Anshu Chauhan
    J2me Developer

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    Re: Choice Group

    Hi chauhan,

    i need to create Choice group of type MULTIPLE in that there will be an three choices (A, B, C)and user can select only 1 or 2 option like A,B,C or AB,BC,CA not all option ie ABC. Depending on the value selected i need to set the value for an variable for A selected set x=1,for B set x=2 for c set x=3 like that,
    if user selects two option
    ex:AB selected set x=1.5
    BC selected set x=2.5
    CA selected set x=2

  4. #4
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Choice Group

    OHk lets do the Simple thing

    Create ONe for loop which run up to choice ground data size i mean String Array size you have passed .Now check the getSelected Flag and Make one counter if getSelected Flag True then increase counter and do one more things add all these value which are selected.Like this

    int total_Value,counter;
    for(int i =0;i<size,i++){
    if(choicegroup.getselectedflag){
    counter++;
    total_Value=(i+1)+total_Value;
    }
    }

    int final_Result=total_value/counter;

    Try this .Lets me know and sorry i didn put complete syntex i hope you understand.
    Anshu Chauhan
    J2me Developer

  5. #5
    Registered User
    Join Date
    Nov 2009
    Posts
    14

    Re: Choice Group

    Hi chauhan

    Thank u for ur reply i got the solution i have simple modification to ur code.

    if(item==LeafBase)
    {

    int LeafBase1=LeafBase.getSelectedFlags(res);
    double total_Value=0,counter=0,j;

    for(int i =0;i<3;i++){
    if(LeafBase.isSelected(i)){
    if(LeafBase1<=2){
    counter++;
    System.out.println("final result"+counter);
    total_Value=(i+1)+total_Value;
    System.out.println("final result"+total_Value);
    }
    else{
    alert = new Alert("Error", "You should not select more than\n two option", null, AlertType.ERROR);
    alert.setTimeout(Alert.FOREVER);
    display.setCurrent(alert);
    }
    }
    }
    System.out.println("final counter"+counter);
    System.out.println("final total_Value"+total_Value);
    LB1=(total_Value/counter);
    System.out.println("final result"+LB1);

    }

    This working fine if u see any modification please change it
    Thanks and Regards

  6. #6
    Regular Contributor
    Join Date
    Jul 2008
    Location
    Faridabad(Delhi NCR)
    Posts
    343

    Re: Choice Group

    Welcome buddy
    The code is fine so don't worry
    Anshu Chauhan
    J2me Developer

Similar Threads

  1. Choice Group Multiple
    By mrjayaram in forum Mobile Java General
    Replies: 0
    Last Post: 2010-06-30, 21:07
  2. Choice Group Get selected value
    By kev_Makaveli in forum Mobile Java General
    Replies: 6
    Last Post: 2010-01-04, 11:08
  3. Choice group problem
    By vigneshkrish in forum Mobile Java General
    Replies: 8
    Last Post: 2009-05-13, 13:30
  4. J4ME + Choice group
    By ermohanraja in forum Mobile Java General
    Replies: 4
    Last Post: 2009-01-21, 09:15
  5. Choice Group Oddness
    By mrmop in forum Mobile Java General
    Replies: 1
    Last Post: 2003-12-19, 01:32

Posting Permissions

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