List of EditText Arrays

Is there any way to save the EditText into a list array. For instance,

n1I1 = (EditText) findViewById(R.id.etN1I1); n1I2 = (EditText) findViewById(R.id.etN1I2); n1I3 = (EditText) findViewById(R.id.etN1I3); n2I1 = (EditText) findViewById(R.id.etN2I1); n2I2 = (EditText) findViewById(R.id.etN2I2); n2I3 = (EditText) findViewById(R.id.etN2I3); 

in

 FirstList[]={n1I1,n1I2,n1I3} SecondList[]={n2I1,n2I2,n2I3}. 

I would like to have it so that it is easy for me to track user input. While on it, how can I save the double value (e.g. 31.12) in an arraylist?

Thanks.

+1
source share
2 answers

You have 2 options:

  //Array EditText[] FirstList = {n1I1,n1I2,n1I3}; //or ArrayList List<EditText> FirstList = new ArrayList<EditText>(){{ add(n1I1); add(n1I2); add(n1I3); }}; 
+1
source

use an ArrayList object, not a regular array:

 ArrayList<EditText> firstList = new ArrayList<EditText>(); firstList.add(n1I1); firstList.add(n1I2); firstList.add(n1I3); ArrayList<EditText> secondList = new ArrayList<EditText>(); secondList.add(n2I1); secondList.add(n2I2); secondList.add(n2I3); 
+1
source

All Articles