This is my code..I have created a dynamic screen where i am generating one textview and edittext under a for loop.but after button click it is only getting the last input.I need to get all the inputs of editText and have to pass them to new screen..guyss..plzz help me out.here is my code..
runOnUiThread(new Runnable() {
public void run() {
final LinearLayout findViewById = (LinearLayout) findViewById(R.id.dynamicInputs);
// TextView textView = (TextView) findViewById(R.id.name);
TextView textView = new TextView(Activity_UserInput.this);
textView.setText(map.get(KEY_NAME) + " :");
textView.setTextColor(Color.BLACK);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 17);
findViewById.addView(textView);
final EditText editText = new EditText(
Activity_UserInput.this);
editText.setText("");
editText.setFocusableInTouchMode(true);
editText.requestFocus();
findViewById.addView(editText);
final ArrayList<EditText> allEds = new ArrayList<EditText>();
allEds.add(editText);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// it = new Intent(Activity_UserInput.this,
// Submition_Activity.class);
// it.putExtra("input", arryList);
// System.out.println("get the input"
// + arryList);
String[] string = new String[allEds.size()];
for (int i = 0; i < string.length; i++) {
string[i] = allEds.get(i).getText().toString();
}
}
});
}
});
Here, in your code arraylist of EditText created every time.So initialize allEds at startup
final ArrayList<EditText> allEds = new ArrayList<EditText>();
and then add EditText to arraylist
final EditText editText = new EditText( Activity_UserInput.this);
editText.setText("");
editText.setFocusableInTouchMode(true);
editText.requestFocus();
findViewById.addView(editText);
allEds.add(editText);