title: android : change layout screen in runtime
body: <p>I have two layout xml files. In one Layout I have RecyclerView and another layout just few textViews and button. Now my question is I want to change my layout when RecyclerView is empty. RecyclerView contains list of products which user can remove by tapping on delete icon present in each row of RecyclerView. When user reaches to size zero of list then I want to change layout to other which contains text like <code>your cart is empty please add some products.</code></p>
  
  <p>My first layout look like this.</p>
  
  <p><a href="https://i.stack.imgur.com/GgzUW.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GgzUW.jpg" alt="enter image description here"></a></p>
  
  <p>after deleting all items from list it should look like this. My all xml file are ready.</p>
  
  <p><a href="https://i.stack.imgur.com/JVXYx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JVXYx.jpg" alt="enter image description here"></a></p>
  
  <p>Here is my some code of my adapter.</p>
  
  <blockquote>
    <p>onCreateViewHolder</p>
  </blockquote>
  
  <pre><code>public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = layoutInflater.inflate(R.layout.checkout_single_design, parent, false);
      return new ViewHolder(view);
  }
  </code></pre>
  
  <blockquote>
    <p>delete Icon Click listener</p>
  </blockquote>
  
  <pre><code>    holder.ivDelete.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              openDialog(design);
          }
      });
  </code></pre>
  
  <p>And here is openDialog() method. Here Design is my model class.</p>
  
  <pre><code>public void openDialog(final Design design) {
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setTitle("Confirm");
      builder.setMessage("Remove item from cart?");
      builder.setPositiveButton("YES", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
              designList.remove(design);
              notifyDataSetChanged();
              saveSharedPref(context, "cart", new Gson().toJson(designList));
              Toast.makeText(context, "deleted", Toast.LENGTH_SHORT).show();
              dialog.dismiss();
          }
      });
  
      builder.setNegativeButton("NO", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
          }
      });
  
      AlertDialog alert = builder.create();
      alert.show();
  }
  </code></pre>
  
  <blockquote>
    <p>Design.java</p>
  </blockquote>
  
  <pre><code>public class Design implements Serializable{
  
      public int id;
      public String qualityId;
      public String qualityName;
      public String designId;
      public String designName;
      public String image;
      public String name; //use as shade name
      public String discPercent;
      public String amount;
      public int pcs;
      public String qty;
  }
  </code></pre>
  
  <p>In activity I am just setting adapter to recyclerView.</p>
  
  <pre><code>co_recycler_view.setLayoutManager(new LinearLayoutManager(CheckOutActivity.this));
  co_recycler_view.setHasFixedSize(true);
  adapter = new CheckOutAdapter(CheckOutActivity.this, designList);
  co_recycler_view.setAdapter(adapter);
  </code></pre>
  
  <p>I hope my question is clear to all. I don't know how to achieve this. please suggest.</p>