title: How to change text from another activity?
body: <p>I am creating an Android app - using Android Studio. </p>
  
  <p>The app launches in MainActivity.java which fetches activity_main.xml . On activity_main, the user can select one of 3 buttons. No matter which button they select, it will take them to the SAME layout - primary_layout.xml and the Java class associated with that is PrimaryClass.java .</p>
  
  <p>I have a placeholder in primary_layout. I want this placeholder (id: placeholder) to change according to what button was previously selected.</p>
  Eg. If Button 1 (id: button1) is clicked, then the placeholder must say “Button 1 was clicked.”
  <br>Or let’s say Button 2 (id: button2) was clicked, then the placeholder must say “Button 2 was clicked”. And the same goes for Button 3.
  I have created an intent to open PrimaryClass but I'm not too sure how to code the intent for when the button is clicked. I just don’t know how to change the text of the placeholder, depending on which button the user has clicked. I’ve tried using an ‘if statement’ but it doesn’t seem to work.
  Or instead of creating another activity, should I rather create a fragment, and if I should, how would I code the fragment in this particular app?</p>
  I have attached images and code to better understand.</p>
  
  <p><a href="https://i.stack.imgur.com/6PEMw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6PEMw.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/ipZ7h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ipZ7h.png" alt="enter image description here"></a></p>
  
  <p>And here is my code of my classes and layout files:</p>
  
  <p>MainActivity:</p>
  
  <pre><code>package com.msp.exampleapplication;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  
  public class MainActivity extends AppCompatActivity {
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  }
  </code></pre>
  
  <p>activity_main:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/activity_main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.msp.exampleapplication.MainActivity"&gt;
  
      &lt;Button
          android:text="Button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_alignParentStart="true"
          android:id="@+id/button1"
          android:onClick="clickedButton1" /&gt;
  
      &lt;Button
          android:text="Button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/button1"
          android:layout_alignParentStart="true"
          android:layout_marginTop="27dp"
          android:id="@+id/button2"
          android:onClick="clickedButton2" /&gt;
  
      &lt;Button
          android:text="Button3"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/button2"
          android:layout_alignParentStart="true"
          android:layout_marginTop="32dp"
          android:id="@+id/button3"
          android:onClick="clickedButton3" /&gt;
  
  &lt;/RelativeLayout&gt;</code></pre>
  </div>
  </div>
  
  <br>PrimaryClass:</p>
  
  <pre><code>package com.msp.exampleapplication;
  
  import android.os.Bundle;
  import android.support.v7.app.AppCompatActivity;
  
  public class PrimaryClass extends AppCompatActivity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.primary_layout);
  
      }
  }
  </code></pre>
  
  <p>primary_layout:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:text="{holder}"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:textSize="35sp"
          android:id="@+id/placeholder" /&gt;
  
  &lt;/LinearLayout&gt;</code></pre>
  </div>
  </div>
  </p>