title: How to Save to an Array and display array in listview
body: <p>I use this code to save the contents of a <code>EditText</code> (name) to an array, i'm wanting to then display this array in a list view on another activity. any idea? thanks </p>
  
  <p>SingleItemView:</p>
  
  <pre><code>ArrayList&lt;String&gt; addArray = new  ArrayList&lt;String&gt;();
  Intent intent = new Intent(SingleItemView.this, mygardenMain.class);
  Bundle bundle =new Bundle();
  
  public void onClick(View v) {
          String getInput = txt.getText().toString();
  
          if (addArray.contains(getInput)){
              Toast.makeText(SingleItemView.this,"Plant Already Added",Toast.LENGTH_SHORT).show();
          }
          else if (getInput == null || getInput.trim().equals("")){
              Toast.makeText(SingleItemView.this,"No Plant Selected",Toast.LENGTH_SHORT).show();
          }
          else
          {
              addArray.add(getInput);
              Toast.makeText(SingleItemView.this,"Plant Added",Toast.LENGTH_SHORT).show();
              bundle.putStringArrayList("addArray",addArray);
  
  intent.putExtras(bundle);
                  startActivity(intent);
  </code></pre>
  
  <p>mygardenMain code:</p>
  
  <pre><code>public class mygardenMain extends Activity {
  
  private ListView list;
  private ArrayList&lt;String&gt; addArray;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.mygarden_list);
      list = (ListView) findViewById(R.id.mygardenlist);
  
  
      Bundle bundle = getIntent().getExtras();
      ArrayList&lt;String&gt; addArray = bundle.getStringArrayList("addArray");
  
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(mygardenMain.this,           android.R.layout.simple_list_item_1, addArray);
      list.setAdapter(adapter);
  
  
      }
      }
  </code></pre>