title: Get Data From Dynamically Created EditTexts In A Different Activity
body: <p>Any help with this will be greatly appreciated. I am trying to take data which will be input by the user into dynamically generated EditTexts in one activity and put the data into TextViews in another activity. While it is true I found similar questions elsewhere on this website, I couldn't solve the problem myself so I figured there's something in my code that will jump out at someone. Keep in mind that I've tried to accomplish this in multiple ways so the code might be ugly because I got frustrated and kept trying to implement more and more to make it work.</p>
  
  <p>Activity A (a number of EditTexts are created based on a number the user inputs, and I need to take what the user types in the EditTexts, perhaps in an array???? and move it to Activity B.</p>
  
  <pre><code>    final Button submitButton = new Button(this);
      submitButton.setText("Submit");
      submitButton.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v){
              Intent intent = new Intent(ChoiceMaker.this, Randomizer.class);
              startActivity(intent);
              setContentView(R.layout.randomizer);
  
          }
      });
  
  
      btnCreate.setOnClickListener(new View.OnClickListener() {
          public List&lt;EditText&gt; strings;
  
          @Override
          public void onClick(View v) {
              List&lt;EditText&gt; allEds = null;
              if (edtNoCreate.getText().toString().length() &gt; 0) {
                  try {
                      lnrDynamicEditTextHolder.removeAllViews();
                  } catch (Throwable e) {
                      e.printStackTrace();
                  }
  
                  int length = Integer.parseInt(edtNoCreate.getText().toString());
                  EditText editText;
                  allEds = new ArrayList&lt;EditText&gt;();
  
                  for (int i = 0; i &lt; length; i++) {
                      editText = new EditText(ChoiceMaker.this);
                      allEds.add(editText);
                      editText.setId(i + 1);
                      editText.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
                      editText.setHint("Possible choice " + (i + 1));
                      editText.setTextColor(Color.parseColor("#c0b1ff"));
                      editText.setTextSize(38);
                      lnrDynamicEditTextHolder.addView(editText);
  
  
                  }
  
  
                  LinearLayout layout = (LinearLayout) findViewById(R.id.choiceMakerLayout);
                  layout.addView(submitButton);
                  submitButton.setBackgroundColor(Color.BLUE);
  
                  String[] strings = new String[allEds.size()];
  
                  for(int i=0; i &lt; allEds.size(); i++){
                      strings[i] = allEds.get(i).getText().toString();
                  }
  
                  Intent intent = new Intent(ChoiceMaker.this, Randomizer.class);
                  intent.putExtra("strings", strings);
  
              }
  
          }
  
      }
  </code></pre>
  
  <p>Activity B</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.randomizer);
  
      Intent intent = getIntent();
      String[] stringArray = intent.getStringArrayExtra("strings");
      int textViewCount = 10;
  
      TextView[] textViewArray = new TextView[textViewCount];
  
      for (int i = 0; i &lt; textViewCount; i++) {
          textViewArray[i] = new TextView(this);
          textViewArray[i].setText(stringArray);
  
  
  
  }}
  </code></pre>