title: How can I use findViewById() in this Android Activity?
body: <p>I need to activate and link a ImageButton using findViewById in this class but it won't work. I know it's something to do with not calling setContentView or extending Activity?
  findViewByID is underlined red and says "The method findViewById(int) is undefined for the type BuyTicket" 
  It suggests I create it as a method.</p>
  
  <p>Any help much appreciated, thanks!</p>
  
  <pre><code>package fyp.sbarcoe.tabsswipe;
  
  
  public class BuyTicket extends Fragment 
  {
      ImageButton dubBus, luas, dart ;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
  {       
      dubBus = (ImageButton) findViewById(R.id.dubBus);
      //dubBus.setOnClickListener(new View.OnClickListener() {public void onClick(View v){System.out.println("Dublin Bus");}});
  
      View rootView = inflater.inflate(R.layout.fragment_buy, container, false);      
      return rootView;
  }
  </code></pre>
  
  <p>}</p>