title: NullPointerException VideoView and MediaController on Fragment in android
body: <p>I am developing Galaxy Tab 10.1 app by using honeycomb 3.1 and i have a videoview and mediacontroller in fragment on the right side. I defined VideoView and MediaController in Layout xml file and instantiate and manipulate them in the related java file.</p>
  
  <p>As you guys konw, in the java file, i set VideoView's controller to MediaController and set MediaController's media player to VideoView, i defined.</p>
  
  <p>Below is fragment layout xml file</p>
  
  <pre><code>&lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;VideoView
          android:id="@+id/video"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  
      &lt;MediaController
          android:id="@+id/controller"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and java code file is below</p>
  
  <pre><code>public class ContentFragment extends Fragment {
      private VideoView mVideo;
      private MediaController mController;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.content, null);
          mVideo = (VideoView)view.findViewById(R.id.video);
          mController = (MediaController)view.findViewById(R.id.controller);
          mVideo.setMediaController(mController);
          mController.setMediaPlayer(mVideo);
  
          return view;
      }
  
      public void playVideo(String path) {
          mVideo.setVideoPath(path);
          mVideo.requestFocus();
      }
  }
  </code></pre>
  
  <p>But while running this app, there occurs </p>
  
  <blockquote>
    <p>NullPointerException with
    android.widget.MediaController.show(MediaController.java:305)</p>
  </blockquote>
  
  <p>I tried to solve this error a whole day but i can't get the reason why. actullay there isn't enought information for this.
  Dose any body know what i did wrong? or have solutions?
  Please let me know.</p>
  
  <p>Thanks.</p>