title: How to Make CardViews in Recyclerview Expandable/Collapsable
body: <p>My RecyclerViews list items are CardViews and the each CardView contains an image, textview(title) and another textview(description). </p>
  
  <p>I want the image and the title to show only. But the description will only show when the the arrow is clicked. And when the arrow is clicked again, it'll collapse.</p>
  
  <p><img src="https://i.stack.imgur.com/082HB.png" alt="Collapsed cardview"></p>
  
  <p><img src="https://i.stack.imgur.com/IgKMf.png" alt="Expanded cardview"> </p>
  
  <p><strong>This is MainActivity</strong></p>
  
  <pre><code>public class MainActivity extends AppCompatActivity
          implements NavigationView.OnNavigationItemSelectedListener {
  
      private final String TAG = "MainActivity";
  
  
      //Creating a list of videos
      private List&lt;VideoItems&gt; mVideoItemsList;
  
      //Creating Views
      private RecyclerView recyclerView;
      private RecyclerView.Adapter adapter;
      private ProgressDialog mProgressDialog;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Log.d(TAG, "Device rotated and onCreate called");
  
          //Initializing Views
          recyclerView = (RecyclerView) findViewById(R.id.video_recycler);
          LinearLayoutManager layoutManager = new LinearLayoutManager(this);
          recyclerView.setLayoutManager(layoutManager);
  
  
          //Initializing the videolist
          mVideoItemsList = new ArrayList&lt;&gt;();
          adapter = new VideoAdapter(mVideoItemsList, this);
  
          recyclerView.setAdapter(adapter);
  
  
  
  
          if (NetworkCheck.isAvailableAndConnected(this)) {
  
              //Caling method to get data
              getData();
          } else {
              final Context mContext;
              mContext = this;
              final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
              alertDialogBuilder.setTitle(R.string.alert_titl);
              alertDialogBuilder.setCancelable(false);
              alertDialogBuilder.setIcon(R.mipmap.ic_launcher);
              alertDialogBuilder.setMessage(R.string.alert_mess);
              alertDialogBuilder.setPositiveButton(R.string.alert_retry, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      if (!NetworkCheck.isAvailableAndConnected(mContext)) {
                          alertDialogBuilder.show();
                      } else {
                          getData();
                      }
  
                  }
              });
              alertDialogBuilder.setNegativeButton(R.string.alert_cancel, new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                      finish();
  
                  }
              });
              alertDialogBuilder.show();
  
  
          }
  
  
      //This method will get data from the web api
  
      private void getData(){
  
  
          Log.d(TAG, "getData called");
          //Showing progress dialog
          mProgressDialog = new ProgressDialog(MainActivity.this);
          mProgressDialog.setCancelable(false);
          mProgressDialog.setMessage(this.getResources().getString(R.string.load_video));
          mProgressDialog.show();
  
  
          //Creating a json request
          JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(ConfigVideo.GET_URL,
                  new Response.Listener&lt;JSONArray&gt;() {
                      @Override
                      public void onResponse(JSONArray response) {
                          Log.d(TAG, "onResponse called");
                          //Dismissing the progress dialog
                          if (mProgressDialog != null) {
                              mProgressDialog.hide();
                          }
                          /*progressDialog.dismiss();*/
  
  
                          //calling method to parse json array
                          parseData(response);
  
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
  
                      }
                  });
  
          //Creating request queue
          RequestQueue requestQueue = Volley.newRequestQueue(this);
  
          //Adding request to the queue
          requestQueue.add(jsonArrayRequest);
  
      }
  
      //This method will parse json data
      private void parseData(JSONArray array){
          Log.d(TAG, "Parsing array");
  
          for(int i = 0; i&lt;array.length(); i++) {
              VideoItems videoItem = new VideoItems();
              JSONObject jsonObject = null;
              try {
                  jsonObject = array.getJSONObject(i);
                  videoItem.setVideo_title(jsonObject.getString(ConfigVideo.TAG_POST_TITLE));
                  videoItem.setVideo_body(jsonObject.getString(ConfigVideo.TAG_POST_BODY));
  
                  //Parsing featured_poctureobject
                  JSONObject videoImage = jsonObject.getJSONObject("featured_image");
                  videoItem.setVideo_image(videoImage.getString("guid"));
  
              } catch (JSONException w) {
                  w.printStackTrace();
              }
              mVideoItemsList.add(videoItem);
  
  
          }
  
          adapter.notifyItemRangeChanged(0, adapter.getItemCount());
  
  
      }
  
  
  
  
      @Override
      public void onDestroy() {
          super.onDestroy();
          Log.d(TAG, "onDestroy called");
          if (mProgressDialog != null){
              mProgressDialog.dismiss();
              Log.d(TAG, "mProgress dialog dismissed");
  
          }
      }
  </code></pre>
  
  <p><strong>This is the Adapter</strong></p>
  
  <pre><code>public class VideoAdapter extends RecyclerView.Adapter&lt;VideoAdapter.ViewHolder&gt;{
  
      private ImageLoader imageLoader;
      private Context mContext;
  
      //List of videos
      private List&lt;VideoItems&gt; mVideoItems;
  
  
  
     public VideoAdapter(List&lt;VideoItems&gt; videoItems, Context context) {
         super();
  
         //Getting all videos
         this.mVideoItems = videoItems;
         this.mContext = context;
     }
  
      @Override
      public ViewHolder  onCreateViewHolder (ViewGroup parent, int viewType) {
          View v =  LayoutInflater.from(parent.getContext())
                  .inflate(R.layout.video_summ, parent, false);
          ViewHolder viewHolder = new ViewHolder(v);
          return viewHolder;
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
  
          VideoItems videoList = mVideoItems.get(position);
  
  
          imageLoader = VolleyRequest.getInstance(mContext).getImageLoader();
          imageLoader.get(videoList.getVideo_image(), ImageLoader.getImageListener(holder.videoImage, R.mipmap.ic_launcher, android.R.drawable.ic_dialog_alert));
  
          holder.videoImage.setImageUrl(videoList.getVideo_image(), imageLoader);
          holder.videoTitle.setText(videoList.getVideo_title());
          holder.videoBody.setText(videoList.getVideo_body());
  
      }
  
  
      @Override
      public int getItemCount(){
          //Return the number of items in the data set
          return mVideoItems.size();
      }
  
      class ViewHolder extends RecyclerView.ViewHolder{
          public NetworkImageView videoImage;
          public TextView videoTitle, videoBody, videoAuthor, videoDate;
  
          public ViewHolder (View videoView) {
              super(videoView);
              videoImage = (NetworkImageView) videoView.findViewById(R.id.video_image);
              videoTitle = (TextView) videoView.findViewById(R.id.video_title);
              videoBody = (TextView) videoView.findViewById(R.id.video_body);
  
          }
      }
  
  
  }
  </code></pre>