title: Storing button presses into a list and viewing them in another activity?
body: <p>I am new to android studio and am trying to teach myself the basics. I currently have a number of buttons for various food items (Salad Dressings). Once pressed, I want the food item to be stored in a list, so that once I go to the next activity, I can display it there showing item that was pressed. </p>
  
  <p>SaladDressing.java:</p>
  
  <pre><code>import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  public class SaladDressing extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_salad_dressing);
  
      Button button1 = (Button) findViewById(R.id.BalsamicVinaigrette);
      button1.setText("Balsamic Vinaigrette");
  
      Button button2 = (Button) findViewById(R.id.Caesar);
      button2.setText("Caesar");
  
      Button button3 = (Button) findViewById(R.id.BleuCheese);
      button3.setText("Bleu Cheese");
  
      Button button4 = (Button) findViewById(R.id.HM);
      button4.setText("Honey Mustard");
  
      Button button5 = (Button) findViewById(R.id.LoCalItalian);
      button5.setText("Lo-Cal Italian");
  
      Button button6 = (Button) findViewById(R.id.CM);
      button6.setText("Chipotle Mayo");
  
      Button button7 = (Button) findViewById(R.id.Ranch);
      button7.setText("Ranch");
  
      Button button8 = (Button) findViewById(R.id.ThousandIsland);
      button8.setText("Thousand Island");
  
      button1.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button2.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button3.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button4.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button5.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button6.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
      button7.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
      button8.setOnClickListener(new View.OnClickListener(){
          public void onClick(View v) {
              startActivity(new Intent(SaladDressing.this, Orderlist.class));
          }
      });
  
  
  
  
  }
  }
  </code></pre>
  
  <p>I am not sure however, how I can save those presses and display them on the Orderlist.java and layout file. I think I would have to use an ArrayList, but I'm not sure how to use it for storing button presses.</p>
  
  <p>Thanks!</p>