title: Android setText() Different Layout File
body: <p>I'm trying to use setText to show different text within the same layout everytime someone clicks a different picture.
  So all the layout files stay the same the only thing that needs to change is the android:text in that layout.</p>
  
  <p>I've created a class with case statement for when someone presses on a picture and then call setText().</p>
  
  <p>But it looks like the setText isn't even called. because I can see my Log.v that is called within the same case statement but the text doesn't change.</p>
  
  <p>PictureInfo.java</p>
  
  <pre><code>public class PictureInfo extends Activity implements OnClickListener {
          private static final String TAG = "Popup";
  
          public TextView infoText;
  
          /** Called when the activity is first created. */
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.main);
  
              final LayoutInflater  inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              infoText = (TextView)inflater.inflate(R.layout.information, null);
  
  
  
              View a1Button = findViewById(R.id.a1);
              a1Button.setOnClickListener(this);
  
  
  
          }
  
          @Override
          public void onClick(View v)
              {
                  switch(v.getId())
                  {
  
                      case R.id.a1:
  
                      Intent a = new Intent(this, Information.class);
                      startActivity(a);
                      Log.v(TAG, "Change setText");
                      infoText.setText(R.string.a2_text);
                      break;
                  }
  
              }
  
      }
  </code></pre>
  
  <p>information.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  
     &lt;TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/information_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/a1_text"
        /&gt;
  </code></pre>