user3588336
user3588336

Reputation: 1

How to retrieve data from EditText created dynamically in android

How to retrieve data from EditText created dynamically in android

this is my exemple :

EditText val ;



    for(int i=0;i<alltowerslist.length();i++){

               JSONObject description = sub_towers.getJSONObject("description");
               String data2 =description.getString("data");



                       val=new EditText(Dynamique2.this);
                       val.setText(data2);
                       val.setId(i);
                       layout.addView(val); 
                       val.setVisibility(View.VISIBLE);

                       }

Upvotes: 0

Views: 82

Answers (1)

Pradeep Kumar
Pradeep Kumar

Reputation: 877

Use the line of code

   EditText val[]=new EditText[alltowerslist.length()] ;
   String upDateVal[]=new String[val.length()] ;



        for(int i=0;i<alltowerslist.length();i++){

                   JSONObject description = sub_towers.getJSONObject("description");
                   String data2 =description.getString("data");



                           val[i]=new EditText(Dynamique2.this);
                           val[i].setText(data2);
                           val[i].setId(i);
                           layout.addView(val[i]); 
                           val[i].setVisibility(View.VISIBLE);

                           }

now you can access them at which position editText detail you want. for EX: val[1].getText().toString()

atEnd getting values from editTexts.

 for(int i=0;i<val.length();i++){        
                       upDateVal[i]=val[i].getText().toString();
 }

Upvotes: 3

Related Questions