从Blackberry中动态生成的basicEditField获取价值

时间:2012-11-15 12:12:40

标签: blackberry user-interface java-me

我正在开发一个我需要生成动态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());
}

1 个答案:

答案 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());

            }