title: Android button setOnClickListener error in a fragment
body: <p>I am trying to handle a button click in fragment in android but I am having error at <code>setOnClickListener</code>. The button is not in the fragment but in a custom listview. Here is the code and xml that I am using.</p>
  
  <p><strong>programim_fragment_main.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"    
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
       &lt;ListView
           android:id="@+id/listProgramim"
           android:layout_width="match_parent"
           android:layout_height="370dp"
           android:layout_alignParentLeft="true"
           android:layout_alignParentTop="true" 
           tools:listitem="@layout/list_programim"&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>listProgramim.xml:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
   &lt;Button
          android:id="@+id/btnRemove"
          android:layout_width="50dp"
          android:layout_height="50dp"
          android:layout_alignParentRight="true"
          android:src="@drawable/iconRemove" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>Fragment.java</strong>:</p>
  
  <pre><code>public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.programim_fragment_main, container, false);
  
           Button button = (Button) rootView.findViewById(R.id.btnRemove);
             button.setOnClickListener(new OnClickListener()
             {
                       @Override
                       public void onClick(View v)
                       {
                          // do something
                       } 
             });
  
      lstAdapter.insert(new ListClassProgramim("", 0), 0);
  
      return rootView;
  }
  </code></pre>
  
  <p>what may cause this error?</p>