title: Button Inside Android ListView doesnt respond to clicks
body: <p>I have a default ListView that i have added my custom views for the list items, but the buttons inside of these views are not clickable most of the time. I output a Log.v when the button receives a click event, but i have to tap the button almost a dozen times before it will register the click.</p>
  
  <p>The other problem related tot his that i am having is that when the button is pressed i want an animation to happen revealing a menu sliding out from beneath it. At the moment i have tried several different methods like making a custom class for the views versus just using a layout inflater to get the relativeLayout object for the view, but nothing is working properly. I have even tried using <code>listview.getAdapter().notifyDataSetChanged();</code> but that only has a pop-into-place for the extended view when i want an animation.</p>
  
  <p>I have searched everywhere and it seems like the only possible solutions are to either rewrite my own custom listview or to use a linearlayout with a scrollview. The latter seems easier but i dont think it is nearly as optimized as the listview is.</p>
  
  <p>Any suggestions would be greatly appreciated, if you need to see some code, please let me know...</p>
  
  <p>Thanks!</p>
  
  <p>UPDATE: </p>
  
  <p>the <code>getView()</code> contains this:</p>
  
  <pre><code>    Holder hold;
      convertView = friends.get(position);
      hold = new Holder();
      hold.pos = position;
      convertView.setTag(hold);
      return convertView;
  </code></pre>
  
  <p>basically i pass an <code>ArrayList&lt;RelativeLayout&gt;</code>, at the moment, to the Adapter so that i dont have to create a new view each time and so that the animation will stay animated when i scroll down...</p>
  
  <p>inside the <code>OnCreate()</code> for this activity i set that <code>ArrayList&lt;RelativeLayout&gt;</code> with this next code, but this is only temporary as i plan to use another method later, like an Async task or something so that this view contains some data...</p>
  
  <pre><code>    RelativeLayout temp;
      for(int i=0; i&lt;30; i++){
          temp = (RelativeLayout) inflater.inflate(R.layout.list_item, null);
  
          final LinearLayout extraListItemInfo = (LinearLayout) temp.findViewById(R.id.extraListItemInfo);
  
          Button infoBtn = (Button) temp.findViewById(R.id.infoBtn);
          infoBtn.setOnClickListener(new OnClickListener(){
              @Override
              public void onClick(View v) {
                  Log.v("ListItem", "Button has been clicked... ");
                  extraListItemInfo .setVisibility(View.VISIBLE);
  
                  ExpandAnimation closeAnim = new ExpandAnimation(extraListItemInfo , animHeight);
                  closeAnim.setDuration(750);
                  closeAnim.setFillAfter(true);
  
                  if(extraListItemInfo .getTag() == null || !extraListItemInfo .getTag().equals("expanded")){
                      extraListItemInfo .getLayoutParams().height = 0;
                      friendInfoList.startAnimation(closeAnim.expand());
                      extraListItemInfo .setTag("expanded");
                  }else if(extraListItemInfo .getTag().equals("expanded")){
                      extraListItemInfo .startAnimation(closeAnim.collapse());
                      extraListItemInfo .setTag("closed");
                  }
                  //((BaseAdapter) listview.getAdapter()).notifyDataSetChanged(); i tried it here once but then left it
      //as the only action inside the listview's onitemclick()
              }
          });
  
          listItems.add(temp);
      }
  </code></pre>
  
  <p>this is the list item that i am using:</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:background="@color/darkgrey"
      android:paddingBottom="5dp" &gt;
  
      &lt;LinearLayout
          android:id="@+id/extraListItemInfo "
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_below="@+id/listItemInfo"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"
          android:layout_marginTop="-10dp"
          android:background="@color/grey"
          android:orientation="vertical"
          android:visibility="gone" &gt;
  
  
          &lt;RelativeLayout
              android:id="@+id/RelativeLayout04"
              android:layout_width="match_parent"
              android:layout_height="@dimen/activity_list_height"
              android:layout_marginTop="5dp" &gt;
  
              &lt;ImageView
                  android:id="@+id/ImageView04"
                  android:layout_width="wrap_content"
                  android:layout_height="25dp"
                  android:layout_margin="5dp"
                  android:src="@drawable/logo_d" /&gt;
  
              &lt;TextView
                  android:id="@+id/TextView04"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_toRightOf="@+id/ImageView04"
                  android:text="TextView"
                  android:textColor="@color/black"
                  android:textSize="17dp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:id="@+id/RelativeLayout03"
              android:layout_width="match_parent"
              android:layout_height="@dimen/activity_list_height" &gt;
  
              &lt;ImageView
                  android:id="@+id/ImageView03"
                  android:layout_width="wrap_content"
                  android:layout_height="25dp"
                  android:layout_margin="5dp"
                  android:src="@drawable/logo_d" /&gt;
  
              &lt;TextView
                  android:id="@+id/TextView03"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_toRightOf="@+id/ImageView03"
                  android:text="TextView"
                  android:textColor="@color/black"
                  android:textSize="17dp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:id="@+id/RelativeLayout02"
              android:layout_width="match_parent"
              android:layout_height="@dimen/activity_list_height" &gt;
  
              &lt;ImageView
                  android:id="@+id/ImageView02"
                  android:layout_width="wrap_content"
                  android:layout_height="25dp"
                  android:layout_margin="5dp"
                  android:src="@drawable/logo_d" /&gt;
  
              &lt;TextView
                  android:id="@+id/TextView02"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_toRightOf="@+id/ImageView02"
                  android:text="TextView"
                  android:textColor="@color/black"
                  android:textSize="17dp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:id="@+id/relativeLayout1"
              android:layout_width="match_parent"
              android:layout_height="@dimen/activity_list_height" &gt;
  
              &lt;ImageView
                  android:id="@+id/imageView1"
                  android:layout_width="wrap_content"
                  android:layout_height="25dp"
                  android:layout_margin="5dp"
                  android:src="@drawable/logo_d" /&gt;
  
              &lt;TextView
                  android:id="@+id/textView1"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_toRightOf="@id/imageView1"
                  android:text="TextView"
                  android:textColor="@color/black"
                  android:textSize="17dp" /&gt;
          &lt;/RelativeLayout&gt;
  
          &lt;RelativeLayout
              android:id="@+id/RelativeLayout01"
              android:layout_width="match_parent"
              android:layout_height="@dimen/activity_list_height"&gt;
  
              &lt;ImageView
                  android:id="@+id/ImageView01"
                  android:layout_width="wrap_content"
                  android:layout_height="25dp"
                  android:layout_margin="5dp"
                  android:src="@drawable/logo_d" /&gt;
  
              &lt;TextView
                  android:id="@+id/TextView01"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:layout_centerVertical="true"
                  android:layout_toRightOf="@+id/ImageView01"
                  android:text="TextView"
                  android:textColor="@color/black"
                  android:textSize="17dp" /&gt;
          &lt;/RelativeLayout&gt;
      &lt;/LinearLayout&gt;
          &lt;RelativeLayout
          android:id="@+id/listItemInfo"
          android:layout_width="wrap_content"
          android:layout_height="95dp"
          android:background="@drawable/friend_cell_background2x"
          android:clickable="true" &gt;
  
  
          &lt;RelativeLayout
              android:id="@+id/leftLayout"
              android:layout_width="90dp"
              android:layout_height="match_parent" &gt;
              &lt;ImageView
                  android:id="@+id/imgCompany"
                  android:layout_width="60dp"
                  android:layout_height="50dp"
                  android:layout_centerHorizontal="true"
                  android:layout_marginLeft="10dp"
                  android:layout_marginTop="10dp"
                  android:scaleType="centerInside"
                  android:src="@drawable/user2x" /&gt;
              &lt;ImageView
                  android:id="@+id/imageView2"
                  android:layout_width="40dp"
                  android:layout_height="40dp"
                  android:layout_alignParentBottom="true"
                  android:layout_centerHorizontal="true"
                  android:scaleType="fitXY"
                  android:src="@drawable/online_indicator2s" /&gt;
  
          &lt;/RelativeLayout&gt;
  
  
          &lt;LinearLayout
              android:id="@+id/linearLayout1"
              android:layout_width="wrap_content"
              android:layout_height="50dp"
              android:layout_marginTop="5dp"
              android:layout_toRightOf="@+id/leftLayout"
              android:background="@android:color/transparent"
              android:gravity="left|center"
              android:orientation="vertical"
              android:paddingLeft="5dp" &gt;
  
  
              &lt;TextView
                  android:id="@+id/lblCompanyName"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Contact Name"
                  android:textColor="@color/white"
                  android:textSize="18dp"
                  android:textStyle="bold" &gt;
  
              &lt;/TextView&gt;
  
  
              &lt;TextView
                  android:id="@+id/lblReawrdDesc"
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:text="Last Played Offer"
                  android:textColor="@color/white"
                  android:textSize="17dp" &gt;
  
              &lt;/TextView&gt;
          &lt;/LinearLayout&gt;
  
          &lt;ImageView
              android:id="@+id/imageView4"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentRight="true"
              android:layout_alignParentTop="true"
              android:layout_marginRight="5dp"
              android:src="@drawable/facebook_btn2x" /&gt;
          &lt;Button
              android:id="@+id/infoBtn"
              style="?android:attr/buttonStyleSmall"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentBottom="true"
              android:layout_alignRight="@+id/imageView4"
              android:background="@drawable/info_btn2x"
              android:clickable="true" /&gt;
  
          &lt;TextView
              android:id="@+id/textView2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_marginBottom="13dp"
              android:layout_toLeftOf="@+id/infoBtn"
              android:text="Follows 30+"
              android:textColor="@color/white"
              android:textSize="11dp" /&gt;
  
          &lt;Button
              android:id="@+id/button1"
              style="?android:attr/buttonStyleSmall"
              android:layout_width="75dp"
              android:layout_height="20dp"
              android:layout_alignParentBottom="true"
              android:layout_marginBottom="10dp"
              android:layout_marginRight="10dp"
              android:layout_toLeftOf="@+id/textView2"
              android:background="@drawable/fan_btn2x"
              android:text="Fans 30+"
              android:textColor="@color/white"
              android:textSize="11dp" /&gt;
  
  
          &lt;ImageView
              android:id="@+id/imageView5"
              android:layout_width="40dp"
              android:layout_height="40dp"
              android:layout_alignParentTop="true"
              android:layout_toLeftOf="@+id/imageView4"
              android:src="@drawable/google_btn2x" /&gt;
  
      &lt;/RelativeLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>sorry for any layout problems that may make things difficult to read... but i hope this helps you guys to understand my problem... Thanks</p>
  
  <p>UPDATE 2:</p>
  
  <p>All of these answers have been helpful in some way, but i think the main issue that i must first fix is why the buttons do not receive click events until i have first scrolled away from that listItem, then back to it, then clicked the button again... If someone can help find a solution to THAT i <strong>think</strong> that everything else will be much easier to solve...
  Thanks...</p>
  
  <p>A screenshot as requested, but remember that this shot was taken on a samsung galaxy tab 10.1 and due to me using the same layout for this larger screen, it looks much different from what it does on the phone i usually test with (Motorola droid x that isnt rooted and cant take screenshots...)</p>
  
  <p><img src="https://i.stack.imgur.com/naNBH.jpg" alt="enter image description here"></p>
  
  <p>Another Update:
  I managed to get the clicking and animation working nicely by Extending ArrayAdapter instead of base adapter. Sadly i am still experiencing problems as only the bottom half of the list is clickable. The top half of the list still behaves as before with the very glitchy click events... Any ideas as to what is happening this time? Thanks...</p>