Create a card with recyclerview
<p>my main activity has imageview and I want to create a new card when I clicked it and I wanna manage them. How can add card to layout when I clicked imageview .Here is my cardview layout xml <strong>card_view.xml</strong> </p>

<blockquote>
  <p></p>

<pre><code>&lt;android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/cv"
    &gt;

    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        &gt;
        &lt;TextView
            android:layout_width="300dp"
            android:layout_height="150dp"
            android:text="I'm here"
            android:id="@+id/textView"
            /&gt;
    &lt;/RelativeLayout&gt;

&lt;/android.support.v7.widget.CardView&gt; &lt;/LinearLayout&gt;
</code></pre>
</blockquote>

<p>card class holding just a string</p>

<pre><code>public class Card {
String information;
public void setInformation(String info)
{
    information=info;
}
public String getInformation()
{
    return information;
}
</code></pre>

<p>and here is my adapter</p>

<pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.MyViewHolder&gt; {

private LayoutInflater inflater;
private List&lt;Card&gt; cards;

public MyAdapter (Context context,List&lt;Card&gt; cards)
{
    inflater=LayoutInflater.from(context);
    this.cards=cards;
}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view= inflater.inflate(R.layout.card_view,parent,false);
    MyViewHolder holder=new MyViewHolder(view);
    return holder;
}

@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
    holder.textview.setText(cards.get(position).information);
}

@Override
public int getItemCount() {
    return cards.size();
}

public class MyViewHolder extends RecyclerView.ViewHolder
{
    TextView textview;
    CardView cardView;
    public MyViewHolder(View itemView) {
        super(itemView);
        textview=(TextView)itemView.findViewById(R.id.textView);
        cardView=(CardView)itemView.findViewById(R.id.cv);
    }
}
</code></pre>

<p>and main</p>

<pre><code>private MyAdapter adapter;
private List&lt;Card&gt; cards=new ArrayList&lt;&gt;();
private RecyclerView rv;
protected void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    rv = (RecyclerView)findViewById(R.id.rv);
    rv.setHasFixedSize(true);

    final LinearLayoutManager llm=new LinearLayoutManager(getApplicationContext());
    rv.setLayoutManager(llm);

    final Card current=new Card();
    adapter=new MyAdapter(this,cards);
    rv.setAdapter(adapter);


    iView=(ImageView)findViewById(R.id.imageView);

    iView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            current.information="Hello";
            cards.add(current);

            //mLayout.addView();
                }
            });
</code></pre>