title: Getting error "cannot resolve findViewById(int)'
body: <p>I have a main activity and when I press a button, i am navigated to a swipe Tab view. Now I want to have a Clickable Button in these tabs and present a toast when the button is pressed. Here is the code I use:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Button;
  
  public class laundry extends Fragment {
  Button btn_service;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      return inflater.inflate(R.layout.activity_laundry, container,false);
      btn_service = (Button) findViewById(R.id.btn_service);
      btn_service.setOnClickListener(this);
  }
  </code></pre>
  
  <p>But the findViewById is not a know symbol to this activity. Is there an alternative way to incorporate clickable buttons in fragment activity like above?</p>
  
  <p>Ran the project and I get this error. ( I cant know if the suggested changes worked, my app crashed with the following error) This is a fragment activity and I am trying to generate a toast when a button is clicked. </p>
  
  <pre><code>public class in_room_dining extends Fragment
  {
  Button btn_order;
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState)
  {
      // TODO Auto-generated method stub
  
      btn_order.setOnClickListener(new OnClickListener()
  {
   public void onClick(View v)
  {
  Toast.makeText(getActivity(), "text", Toast.LENGTH_SHORT).show();
  }
  });
   return inflater.inflate(R.layout.activity_in_room_dining, container, false);
  }
  }
  </code></pre>
  
  <p>The error I got is :</p>
  
  <pre><code>11-29 10:57:42.820      938-938/com.appt.shreyabisht.staymax E/AndroidRuntime﹕ FATAL EXCEPTION:     main
  Process: com.appt.shreyabisht.staymax, PID: 938
  java.lang.NullPointerException
          at com.appt.shreyabisht.staymax.in_room_dining.onCreateView(in_room_dining.java:23)
          at android.support.v4.app.Fragment.performCreateView(Fragment.java:1504)
  </code></pre>
  
  <p>(in_room_dining.java:23) is btn_order.setOnClickListener(new OnClickListener()</p>