title: How to change fragment's textView's text from activity
body: <p>I cannot find how to change fragment's <code>textview</code> from an <code>Activity</code>. I have 4 files :</p>
  
  <pre><code>MainActivity.java
  activity_main.xml
  FragmentClass.java
  frag_class.xml
  </code></pre>
  
  <p>frag_class.xml has textView, I want to change the text from MainActivity.java.
  FragmentClass extends Fragment, this fragment is displayed in MainActivity
  FragmentClass has:</p>
  
  <pre><code>public void changeText(String text){
   TextView t = (TextView) this.getView().findViewById(R.id.tView);
   t.setText(text);
  }
  </code></pre>
  
  <p>and in MainActivity I tried this:</p>
  
  <pre><code>FragmentClass fc = new FragmentClass();
  fc.changeText("some text");
  </code></pre>
  
  <p>But sadly this code gives me NullPointerException at <code>fc.changeText("some text");</code>
  I've also tried changing the text directly from MainActivity with:</p>
  
  <pre><code> TextView t = (TextView) this.getView().findViewById(R.id.tView);
   t.setText(text);
  </code></pre>
  
  <p>which Failed.</p>
  
  <p><strong>[EDIT]</strong>
  The full code is <a href="http://pastebin.com/NQBieFLi" rel="noreferrer">here</a></p>