Discussion Board

Results 1 to 2 of 2

Thread: textfield[]

  1. #1
    Regular Contributor
    Join Date
    Dec 2009


    I want to add the textfields dynamically

    if(item == choiceGroup)
    // BillPayment.deleteAll();
    RecordStore rs =null;
    rs = RecordStore.openRecordStore("BillStore",true);
    String[] s1 = new String[rs.getNumRecords()];
    String[] s2 = null;
    byte[] recData;
    String FLAGSTRING,s;
    for (int i = 1; i <= rs.getNumRecords(); i++)
    recData = new byte[rs.getRecordSize(i)];
    int length = rs.getRecord(i,recData,0);
    FLAGSTRING = new String(recData,0,length);
    s = FLAGSTRING.substring(0,FLAGSTRING.length());

    String bill_type = s.substring(0,s.indexOf('='));//billname

    String r_data = s.substring(s.indexOf('=')+1, s.length());
    int spl_fld = splitData(r_data, ',', 0);//splits the data

    for(int j = 0; j <= spl_fld; j++)
    comp_data = con_str[j];
    String text_name = con_str[j].substring(0, con_str[j].indexOf('%'));
    String type = con_str[j].substring(con_str[j].indexOf('%')+1, con_str[j].lastIndexOf('%'));
    int size = Integer.parseInt(con_str[j].substring(con_str[j].lastIndexOf('%')+1, con_str[j].length()));
    dtype = TextField.ANY;
    //textField = new TextField("Merchant Key", null, 32, TextField.ANY);
    tf[j] = new TextField(text_name, "", size, dtype);
    // tf = new TextField(text_name, "", size, dtype);

    }else if(type.equalsIgnoreCase("int")){
    dtype = TextField.NUMERIC;
    tf[j] = new TextField(text_name, "", size, dtype);
    // BillPayment.append(tf[j]);

    but here im getting NullPointer Exception...when using normal tf the textfields are added but when i want to get data from respected fields then how to call i.e tf.getString() since that is in loop it is added but the same textfield tf used for all.......

    Please anyone help me....

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Cheshire, UK

    Re: textfield[]

    Do you know where you get the NullPointerException? Finding out would really help you...

    Oh, beware of equalsIgnoreCase()... it only works on devices with CLDC-1.1, not 1.0, so you might your code breaks on some older devices.


Posting Permissions

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