there are several ways to accomplish this.
I prefer to add Linearlayouts dynamically. It´s easy and you can Display nearly every data you want.
First: Take your .xml file and name it into "show_data_item"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="100sp"
android:weightSum="2"
android:id="@+id/show_data_item">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2sp"
android:background="#000000"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0sp"
android:layout_weight="1"
android:weightSum="2">
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
<TextView
android:id="@+id/col1"
android:layout_width="wrap_content"
android:text="Display Data Col1"
android:layout_weight="1"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
<TextView
android:id="@+id/col2"
android:text="Display Data Col2"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2sp"
android:background="#000000"/>
<LinearLayout
android:layout_height="0sp"
android:layout_weight="1"
android:weightSum="2"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
<TextView
android:id="@+id/col3"
android:layout_width="wrap_content"
android:text="Display Data Col3"
android:layout_weight="1"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
<TextView
android:id="@+id/col4"
android:layout_width="wrap_content"
android:text="Display Data Col4"
android:layout_weight="1"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_width="2sp"
android:layout_height="match_parent"
android:background="#000000"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2sp"
android:background="#000000"/>
</LinearLayout>
Step 2: Create an xml Layout for your activity and don´t forget to add it to "manifest.xml", like this (made it with a scrollview so that you have unlimited space) :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/displaydata"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"></LinearLayout>
</ScrollView>
</LinearLayout>
Step 3: Create an class in java which fill´s the textviews with your col1-4, and add this to your "id/displaydata" with the funktion:
myView.addview(show_data_item); //myView is an Object of LinearLayout and show_data_item is also a object of LinearLayout.
This is how you do it.
You can also use a List/RecylerView and add your data with an Adapter. You still need an Layout for your show_data_item.
Here is a code example for this
All ways leads to rome, i guess.