我正在开发一个我需要生成动态EditField
的应用。我能够生成这个,但是当我尝试从这些字段中获取值时,我会在屏幕上为所有字段生成最后EditField
的值。
我在下面粘贴了一些J2ME代码,但我不知道如何通过BlackBerry API调用获得相同的效果。
EditField ef;
for(int i = 0; i < 10; i++){
EditField ef = new EditField("Name : "+i, "");
add(ef);
add(new SeparatorField());
}
for(int i = 0; i < 10 ; i++){
System.out.println(""+ef.getText());
}
private TextField fld, fld1;
for (int i = 0; i < 5; i++) {
fld = new TextField("Name :", null, 30, TextField.ANY);
append(fld);
}
for (int i = 0; i < 5; i++) {
fld1 = (TextField) this.get(i);
System.out.println(""+fld1.getString());
}
答案 0 :(得分:0)
I got my problem Solved. This answer is for those who are interested in it.
EditField ef;
Hashtable allEds = new Hashtable();
for(int i = 0; i < 10; i++){
EditField ef = new EditField("Name : "+i, "");
add(ef);
add(new SeparatorField());
allEds.put(""+i, ef);
}
Enumeration e = allEds.elements();
while(e.hasMoreElements()){
System.out.println(""+e.nextElement().toString());
}