title: Handle Button Clicks in CursorAdapter
body: <p>I want to achieve drop down and sum up for a <code>View</code> in my ListView Data is being fetched from the database and am using a cursor adapter, I have tried to add <code>onClickListner</code> for the button in <code>onItemClickListner</code> But no Success. <br>
  The problem I am facing is When button <code>DROPDOWN</code> is clicked it will make <code>relative layout</code> Visible but when clicked again it won't <code>relative layout</code>  visibility to <code>GONE</code> <br></p>
  <p>Heres my Code for CursorAdapter<br></p>
  <pre><code>public class ProductViewCursorAdapter extends CursorAdapter {
      private CardView cv_singleItem;
      private RelativeLayout infoLayout;
      private Button dropDown;
      public ProductViewCursorAdapter(Context context, Cursor c) {
          super(context, c, 0);
      }
  
      @Override
      public View newView(Context context, Cursor cursor, ViewGroup parent) {
          return LayoutInflater.from(context).inflate(R.layout.custom_product_view_listview,parent,false);
      }
  
      @Override
      public void bindView(View view, Context context, Cursor cursor) {
          cv_singleItem = view.findViewById(R.id.cv_custom_single_product);
          infoLayout = view.findViewById(R.id.layout_dropdown_relative);
          dropDown = view.findViewById(R.id.expand_user_info_listView);
          dropDown.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (infoLayout.getVisibility() == View.GONE){
                      TransitionManager.beginDelayedTransition(cv_singleItem,new AutoTransition());
                      infoLayout.setVisibility(View.VISIBLE);
                      dropDown.setBackgroundResource(R.drawable.ic_sumup);
                  }else{
                      Log.i(&quot;THIS IS TEST&quot;,&quot;DEMO VIEW &quot;+ infoLayout.getVisibility());
                      TransitionManager.beginDelayedTransition(cv_singleItem,new AutoTransition());
                      infoLayout.setVisibility(View.GONE);
                      dropDown.setBackgroundResource(R.drawable.ic_dropdown);
                  }
              }
          });
  
      }
  }
  </code></pre>
  <p>ListView single View XML<br></p>
  <pre><code>&lt;RelativeLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
  
      &lt;androidx.cardview.widget.CardView
          android:id=&quot;@+id/cv_custom_single_product&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          style=&quot;@style/TextAppearance.AppCompat.Title&quot;&gt;
          &lt;LinearLayout
              android:background=&quot;#D5000000&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;&gt;
              &lt;RelativeLayout
                  android:id=&quot;@+id/image_layout_main&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;&gt;
                  &lt;ImageView
                      android:id=&quot;@+id/iv_product_image_listView&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:scaleType=&quot;fitCenter&quot;
                      android:src=&quot;@drawable/selimage&quot;
                      android:layout_height=&quot;200dp&quot;/&gt;
                  &lt;TextView
                      android:id=&quot;@+id/tv_no_image_available&quot;
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;No Image Available&quot;
                      android:textAlignment=&quot;center&quot;
                      android:paddingTop=&quot;5dp&quot;
                      android:textSize=&quot;15sp&quot;
                      android:textStyle=&quot;bold|italic&quot;
                      android:textColor=&quot;@color/white&quot;/&gt;
  
                  &lt;TextView
                      android:id=&quot;@+id/tv_product_name_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;Kurti&quot;
                      android:textSize=&quot;18sp&quot;
                      android:textColor=&quot;#FFFFFF&quot;
                      android:fontFamily=&quot;sans-serif-black&quot;
                      android:textStyle=&quot;italic&quot;
                      android:layout_marginLeft=&quot;20dp&quot;
                      android:layout_below=&quot;@id/iv_product_image_listView&quot;
                      android:layout_marginTop=&quot;-25dp&quot;/&gt;
                  &lt;Button
                      android:id=&quot;@+id/expand_user_info_listView&quot;
                      android:layout_alignParentEnd=&quot;true&quot;
                      android:layout_below=&quot;@id/iv_product_image_listView&quot;
                      android:focusable=&quot;false&quot;
                      android:layout_marginTop=&quot;-49dp&quot;
                      android:layout_marginEnd=&quot;8dp&quot;
                      android:layout_width=&quot;50dp&quot;
                      android:layout_height=&quot;50dp&quot;
                      android:background=&quot;@drawable/ic_dropdown&quot;/&gt;
              &lt;/RelativeLayout&gt;
              &lt;RelativeLayout
                  android:id=&quot;@+id/layout_dropdown_relative&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:visibility=&quot;gone&quot;
                  android:layout_marginStart=&quot;15dp&quot;
                  android:layout_marginEnd=&quot;15dp&quot;
                  android:layout_marginTop=&quot;10dp&quot;
                  android:layout_marginBottom=&quot;10dp&quot;&gt;
                  &lt;TextView
                      android:id=&quot;@+id/tv_date_dropdown_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;2020-12-14&quot;
                      android:textAppearance=&quot;?android:textAppearanceMedium&quot;
                      android:textColor=&quot;#E2FFFFFF&quot;
                      android:fontFamily=&quot;sans-serif-condensed&quot;
                      android:textStyle=&quot;bold&quot;
                      android:layout_marginStart=&quot;4dp&quot;/&gt;
                  &lt;TextView
                      android:id=&quot;@+id/tv_profit_dropdown_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;Profit 500&quot;
                      android:textAppearance=&quot;?android:textAppearanceMedium&quot;
                      android:textColor=&quot;#E2FFFFFF&quot;
                      android:fontFamily=&quot;sans-serif-condensed&quot;
                      android:textStyle=&quot;bold&quot;
                      android:layout_marginStart=&quot;4dp&quot;
                      android:layout_alignParentEnd=&quot;true&quot;/&gt;
  
                  &lt;TextView
                      android:id=&quot;@+id/tv_sellingPrice_dropdown_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;Selling Price: 800&quot;
                      android:textAppearance=&quot;?android:textAppearanceMedium&quot;
                      android:textColor=&quot;#E2FFFFFF&quot;
                      android:fontFamily=&quot;sans-serif-condensed&quot;
                      android:textStyle=&quot;bold&quot;
                      android:layout_marginStart=&quot;4dp&quot;
                      android:layout_below=&quot;@id/tv_date_dropdown_listView&quot;
                      android:paddingTop=&quot;3dp&quot;/&gt;
  
                  &lt;TextView
                      android:id=&quot;@+id/tv_actualPrice_dropDown_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;Actual Price: 850&quot;
                      android:textAppearance=&quot;?android:textAppearanceMedium&quot;
                      android:textColor=&quot;#E2FFFFFF&quot;
                      android:fontFamily=&quot;sans-serif-condensed&quot;
                      android:textStyle=&quot;bold&quot;
                      android:layout_marginStart=&quot;4dp&quot;
                      android:layout_alignParentRight=&quot;true&quot;
                      android:layout_below=&quot;@id/tv_profit_dropdown_listView&quot;
                      android:paddingTop=&quot;3dp&quot;/&gt;
  
                  &lt;TextView
                      android:id=&quot;@+id/tv_pending_dropdown_listView&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:text=&quot;Pending: 0&quot;
                      android:textAppearance=&quot;?android:textAppearanceMedium&quot;
                      android:textColor=&quot;#F50057&quot;
                      android:fontFamily=&quot;sans-serif-condensed&quot;
                      android:textStyle=&quot;bold&quot;
                      android:layout_marginStart=&quot;4dp&quot;
                      android:layout_below=&quot;@id/tv_sellingPrice_dropdown_listView&quot;
                      android:paddingTop=&quot;3dp&quot;/&gt;
  
                  &lt;Button
                      android:id=&quot;@+id/btn_update_single_item&quot;
                      android:layout_width=&quot;30dp&quot;
                      android:layout_height=&quot;30dp&quot;
                      android:layout_below=&quot;@id/tv_actualPrice_dropDown_listView&quot;
                      android:layout_alignParentEnd=&quot;true&quot;
                      android:background=&quot;@drawable/ic_update&quot;/&gt;
              &lt;/RelativeLayout&gt;
          &lt;/LinearLayout&gt;
  
      &lt;/androidx.cardview.widget.CardView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>