title: Navigation menu fragment import media player
body: <p>I just made a navigation drawer having some fragments. I want to put some music on one fragment using MediaPlayer so that when button is click it play music but when i add raw resource file androidstudio do red and shows error cannot resolve method.Can anyone help me how to import media player in Menu1 fragment.</p>
  
  <pre><code>public class Menu1 extends Fragment  {
  MediaPlayer mp;
  
  
  
  @Nullable
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      // Inflate the layout for this fragment
      return inflater.inflate(R.layout.fragment_menu1, container, false);
  }
  
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
  
      getActivity().setTitle("Happy B'day Dear");
      mp=MediaPlayer.create(this,R.raw.hpbday);
      Button button=(Button)findViewById(R.id.btnplay);
      button.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              mp.start();
          }
      });
    }
  } 
  </code></pre>