title: implementing OnClickListener for a fragment on android
body: <p>I have a sliding menu project and inside home layout another layout is called as a fragment :</p>
  
  <p>this is the HomeFragment.java :</p>
  
  <pre><code>package info.androidhive.slidingmenu;
  
  import android.app.Fragment;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class HomeFragment extends Fragment {
  
      public HomeFragment(){}
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
  
          View rootView = inflater.inflate(R.layout.fragment_home, container, false);
  
          return rootView;
      }
  }
  </code></pre>
  
  <p>I need to import this click listener inside my java class in order to submit a form .</p>
  
  <pre><code>//CheckFal:
              btnCheckFalAction = (Button) findViewById(R.id.btnCheckFal);
              btnCheckFalAction.setOnClickListener(new OnClickListener() {           
  
                    @Override
                    public void onClick(View v) 
                    {
                        Toast.makeText(this, "Hello World", Toast.LENGTH_LONG).show();
                    }    
                  }
  </code></pre>
  
  <p>But when I add the above code snippet it throws me an error on  undefined methods such as findViewById , OnClickListener , onClick</p>
  
  <p>The button is inside this layout fragment_home.xml</p>
  
  <p>
  
  <pre><code>  &lt;Button
        android:id="@+id/btnCheckFal"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/relativeLayout1"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="19dp"
        android:text="@string/CheckFal" /&gt;
  </code></pre>
  
  <p></p>