I am pretty new in Android.
I have some problems to create a dynamic LinearLayout programmatically. I actually have some information in ArrayLists that I need to display. The problem is that I don't know how many items are in the ArrayList, so I need to create the same layout (LinearLayoutChild) for every item in the ArrayList.
For example, I have created this (in this case, let's say the ArrayLists have 2 items each)
 ArrayList<String> alistA = new ArrayList<String>();
    ArrayList<String> alistB = new ArrayList<String>();
    ArrayList<String> alistC = new ArrayList<String>();
    ArrayList<String> alistD = new ArrayList<String>();
    ArrayList<String> alistE = new ArrayList<String>();
    alistA.add(0, "TextA1");
    alistA.add(1, "TextA2");
    alistB.add(0, "TextB1");
    alistB.add(1, "TextB2");
    alistC.add(0, "TextC1");
    alistC.add(1, "TextC2");
    alistD.add(0, "TextD1");
    alistD.add(1, "TextD2");
    alistE.add(0, "TextE1");
    alistE.add(1, "TextE2");
    int NumberArray = 2;
    for(int i = 0; i<NumberArray;i++){
        // How can i do this?
    }
I want to display it like : alistA[0] -> Tv1 alistB[0] -> Tv2 and so on...
alistA[[1]] -> Tv1 (newly created) alistB[[1]] -> Tv2 (newly created) ...
My XML file :
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.murat.testlol.MainActivity"
android:id="@+id/LinearLayout1"
android:orientation="vertical">
<EditText
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/Et1"/>
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/Btn1"/>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="12"
    android:orientation="horizontal"
    android:id="@+id/LinearLayoutChild">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="vertical"
        android:id="@+id/Ll1">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/Tv1"
            android:gravity="center"
            android:text="TextView1"
            />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="TextView2"
            android:id="@+id/Tv2"
            android:gravity="center"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="vertical"
        android:id="@+id/Ll2">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/Tv3"
            android:gravity="center"
            android:text="TextView3"/>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:id="@+id/Tv4"
            android:text="TextView4"/>
    </LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="4"
        android:orientation="vertical"
        android:id="@+id/Ll3">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/Tv5"
            android:gravity="center"
            android:text="TextView5"/>
    </LinearLayout>
</LinearLayout>
The EditText and button need to stay at the same place.
Thank you.
 
     
     
     
     
    