title: Create RelativeView inside CardView programmatically android studio
body: <p>I am trying to create a history activity page for my app. I get data from an sql table with the users data, and set that to a card. I have created the first card in my History activity, and I do not want to pre-create all the cards, but I do not know how to programmatically add more card views. I have a relative layout inside a card view, so I can organize the data how I want. Here is my xml layout for the activity</p>
  
  <pre><code> &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:tools="http://schemas.android.com/tools"    
       android:layout_width="match_parent"
       xmlns:ads="http://schemas.android.com/apk/res-auto"
       xmlns:card_view="http://schemas.android.com/apk/res-auto"
       android:layout_height="match_parent"
       android:paddingLeft="@dimen/activity_horizontal_margin"
       android:paddingRight="@dimen/activity_horizontal_margin"
       android:paddingTop="@dimen/activity_vertical_margin"
       android:paddingBottom="@dimen/activity_vertical_margin"&gt;
  
      &lt;com.google.android.gms.ads.AdView
          android:id="@+id/adView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="true"
          ads:adSize="BANNER"
          ads:adUnitId="@string/banner_ad_unit_id"&gt;
      &lt;/com.google.android.gms.ads.AdView&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Clear History"
          android:id="@+id/clearSQLite"
          android:layout_above="@+id/adView"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:width="150dp" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Tips"
          android:id="@+id/TipsButton"
          android:width="150dp"
          android:layout_above="@+id/adView"
          android:layout_alignParentRight="true"
          android:layout_alignParentEnd="true"/&gt;
  
      &lt;android.support.v7.widget.CardView
          tools:context="com.winansbros.soccerpredictor.History"
          android:id="@+id/card_view"
          android:layout_gravity="center"
          card_view:cardCornerRadius="4dp"
          card_view:cardElevation="10dp"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
          &lt;RelativeLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
  
              &lt;ImageView
                  android:layout_width="60dp"
                  android:layout_height="60dp"
                  android:id="@+id/team1imageview"
                  android:layout_alignParentTop="true"
                  /&gt;
  
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/team1name"
                  android:layout_centerVertical="true"
                  android:layout_below="@+id/team2name"
                  android:layout_toRightOf="@+id/team1imageview"
                  android:layout_toEndOf="@+id/team1imageview"
                  android:width="100dp"/&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/card1score"
                  android:width="20dp"
                  android:layout_centerVertical="true"
                  android:layout_alignTop="@+id/team1name"
                  android:layout_toRightOf="@+id/team1name"
                  android:layout_toEndOf="@+id/team1name"/&gt;
              &lt;TextView
                  android:layout_width="wrap_content"
                  android:layout_height="wrap_content"
                  android:id="@+id/team2name"
                  android:width="100dp"
                  android:layout_centerVertical="true"
                  android:layout_toLeftOf="@+id/team2imageview"
                  android:layout_toStartOf="@+id/team2imageview"/&gt;
              &lt;ImageView
                  android:layout_width="60dp"
                  android:layout_height="60dp"
                  android:id="@+id/team2imageview"
                  android:layout_centerVertical="true"
                  android:layout_alignParentEnd="true"
                  android:layout_alignParentRight="true"/&gt;
  
          &lt;/RelativeLayout&gt;
  
      &lt;/android.support.v7.widget.CardView&gt;
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>How do I create another version of the card view layout I have in java?
  Thank you in advance</p>