title: How do I add text from an EditText field to different TextViews in android studio
body: <p>I'm relatively new to java and new to android studio, so any explanation would be greatly appreciated. </p>
  
  <p>I want to create an app that allows the user to enter someones name and assign them to one of two teams. I am at the point where the user can add one name to each team but I am unsure how to add multiple names to each team. </p>
  
  <p>In my XML I have a EditText field to enter the name, two buttons to put them in Team 1 or Team 2 and two TextViews to display all the people in each team. </p>
  
  <pre><code>    &lt;EditText
          android:layout_width="106dp"
          android:layout_height="wrap_content"
          android:id="@+id/NameText"/&gt;
  
      &lt;Button
          android:id="@+id/Team1"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:text="Team 1"/&gt;
  
      &lt;Button
          android:id="@+id/Team2"
          android:layout_height="wrap_content"
          android:layout_width="wrap_content"
          android:text="Team 2" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/team1_person1"/&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/team1_person2"
          android:layout_column="1"/&gt;
  </code></pre>
  
  <p>Here is my java code, I have set each button to add the name entered to the TextView for team 1 or team 2, depending on what button was selected. </p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          Button t1button = (Button) findViewById(R.id.Team1);
          Button t2button = (Button) findViewById(R.id.Team2);
  
  
          t1button.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  // --- find the text view --
                  EditText inputText = (EditText) findViewById(R.id.NameText);
                  String str = inputText.getText().toString();
                  TextView newText = (TextView) findViewById(R.id.team1_person1);
                  newText.setText( str);
              }
          });
  
          t2button.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  // --- find the text view --
                  EditText inputText = (EditText) findViewById(R.id.NameText);
                  String str = inputText.getText().toString();
                  TextView newText = (TextView) findViewById(R.id.team1_person2);
                  newText.setText( str);
              }
          });
  
  
  
      }
  }
  
  
  I know I'll need to add more TextViews for each new name, but I'm not sure how this works with only one button. 
  Thanks
  </code></pre>