title: Button onclick inside fragment is not working
body: <p>I am trying to set / override the <code>onclick</code> method for a button (R.id.buy_button) inside one of my views (inside a fragment). The application doesn't return errors. However it does not trigger the onclick method. I'm not sure if my implementation is wrong or perhaps my button is incorrectly configured. Any help / comments / guidance would be appreciated.</p>
  
  <p><strong>My onCreateView is here:</strong></p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View view = inflater.inflate(R.layout.list_item, container, false);
      Button b = (Button) view.findViewById(R.id.buy_button);
      b.setOnClickListener(this);
  
      return inflater.inflate(R.layout.fragment_item_list, container, false);
  }
  </code></pre>
  
  <p><strong>My entire fragment code:</strong></p>
  
  <pre><code>public static class AlbumsFragment extends ListFragment implements View.OnClickListener {
          private static final String ARG_SECTION_NUMBER = "section_number";
  
          public AlbumsFragment() {
          }
  
          @Override
          public void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
          }
  
          @Override
          public void onActivityCreated(Bundle b){
              super.onActivityCreated(b);
  
              ListView listView = getListView();
              List&lt;Album&gt; albums = null;
  
              albums = Album.listAll(Album.class);
              Log.i("ALBUMS", albums.toString());
              ArrayAdapter&lt;Album&gt; adapter =
                      new ArrayAdapter&lt;Album&gt;(getActivity(), R.layout.list_item, R.id.textView,  albums);
              if (!albums.equals("")) {
                  listView.setAdapter(adapter);
              }
          }
  
          @Override
          public void onAttach(Activity activity) {
              super.onAttach(activity);
              ((MainActivity) activity).onSectionAttached(
                      getArguments().getInt(ARG_SECTION_NUMBER));
          }
  
          @Override
          public void onDestroy() {
              super.onDestroy();
          }
  
          @Override
          public void onDetach() {
              super.onDetach();
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
  
              View view = inflater.inflate(R.layout.list_item, container, false);
              Button b = (Button) view.findViewById(R.id.buy_button);
              b.setOnClickListener(this);
  
              return inflater.inflate(R.layout.fragment_item_list, container, false);
          }
  
          public void gotoPurchaseWeb() {
              Context context = getActivity().getApplicationContext();
              Intent intent = new Intent(context, PurchaseSong.class);
              intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
              context.startActivity(intent);
          }
  
          public static AlbumsFragment newInstance(int sectionNumber) {
              AlbumsFragment fragment = new AlbumsFragment();
              Bundle args = new Bundle();
              args.putInt(ARG_SECTION_NUMBER, sectionNumber);
              fragment.setArguments(args);
  
              return fragment;
          }
  
          @Override
          public void onClick(View v) {
              switch (v.getId()) {
                  case R.id.buy_button:
                      Context context = getActivity().getApplicationContext();
                      Intent intent = new Intent(context, PurchaseSong.class);
                      intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                      context.startActivity(intent);
                      break;
              }
          }
      }
  </code></pre>
  
  <p><strong>My list_item.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="wrap_content"
      android:orientation="horizontal"
      android:padding="5dip" &gt;
  
      &lt;!--  ListRow Left sied Thumbnail image --&gt;
      &lt;LinearLayout android:id="@+id/thumbnail"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="3dip"
          android:layout_alignParentLeft="true"
          android:layout_marginRight="5dip"
          android:weightSum="1"
          android:showDividers="middle|end"
          android:visibility="visible"&gt;
  
          &lt;ImageView
              android:id="@+id/list_image"
              android:layout_width="50dip"
              android:layout_height="50dip"
              android:src="@drawable/black"/&gt;
  
          &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android"
              android:id="@+id/textView"
              android:layout_width="@dimen/navigation_drawer_width"
              android:layout_height="wrap_content"
              android:textSize="16sp"
              android:layout_marginTop="@dimen/zero_space"
              android:layout_marginBottom="@dimen/zero_space"
              android:paddingTop="3dp"
              android:paddingLeft="8dp"
              android:paddingRight="5dp"
              android:paddingBottom="0dp"
              android:layout_weight="24.33" /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;Button
          style="@style/ButtonText"
          android:layout_width="wrap_content"
          android:layout_height="@dimen/button_height"
          android:text="@string/buy_album"
          android:id="@+id/buy_button"
          android:background="@drawable/blue_button"
          android:paddingTop="7dp"
          android:layout_centerVertical="true"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"
          android:layout_marginRight="10dp" /&gt;
  </code></pre>
  
  <p><strong>My entire project:</strong>
  <a href="https://github.com/markbratanov/MyFitPlayer/tree/master/Player/src/main/java/com/markbratanov/myfitplayer" rel="noreferrer">https://github.com/markbratanov/MyFitPlayer/tree/master/Player/src/main/java/com/markbratanov/myfitplayer</a></p>
  
  <p>Any help would be appreciated. Thanks.</p>