title: Fragments in Android- Cant dynamically edit text view
body: <p>I get an error when I try and use:
  TextView tv = (TextView) getView().findViewById(R.id.textView1);
  inside my FragmentOne class.</p>
  
  <p>I'm new to fragments and im hoping to learn PagerView but i cant work out how to dynamically change my widgets.</p>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
      FragmentOne mFrag;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          if(savedInstanceState==null){
              mFrag = new FragmentOne();
              FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
              ft.add(R.id.fragment_layout, mFrag).commit();
          }
  
      }
  }
  </code></pre>
  
  <p><strong>layout/activity_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" 
      android:id="@+id/fragment_layout"&gt;
  
     &lt;FrameLayout 
      android:id="@+id/fragment_frame"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>FragmentOne.java</strong></p>
  
  <pre><code>public class FragmentOne extends Fragment {
      TextView tv;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
          View v = inflater.inflate(R.layout.fragment, container, false);
          // Inflate the layout for this fragment
          tv = (TextView) getView().findViewById(R.id.textView1);
          tv.setText("Yellow World!");
          return v;
      }
  }
  </code></pre>
  
  <p><strong>layout/fragment.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Blellow World!" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Log File: <a href="https://www.dropbox.com/home/Projects?select=log.txt" rel="nofollow">https://www.dropbox.com/home/Projects?select=log.txt</a>
  The error is "Unable to start activity"
  The error goes away if i remove the</p>
  
  <pre><code>tv = (TextView) getView().findViewById(R.id.textView1);
              tv.setText("Yellow World!");
  </code></pre>
  
  <p>lines from the FragmentOne class.</p>
  
  <p>I've only learnt fragments today so im sorry if its something simple!</p>