I want to add the textfields dynamically
so
if(item == choiceGroup)
{
// BillPayment.deleteAll();
RecordStore rs =null;
try{
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
//RoutEquNO%varchar%20,RoutQty1%int%10,RobEquiNO%varchar%20,RobQty%int%10
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++)
{
//RoutEquNO%varchar%20
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()));
System.out.println(text_name+","+type+","+size);
if(type.equalsIgnoreCase("varchar"))
{
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);
//BillPayment.append(tf[j]);
}else if(type.equalsIgnoreCase("int")){
dtype = TextField.NUMERIC;
tf[j] = new TextField(text_name, "", size, dtype);
// BillPayment.append(tf[j]);
}
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....

Reply With Quote

