安卓后台通过java代码动态添加布局组件

在java代码中通过循环添加

img

        <!--一条消息-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:layout_marginTop="5dp"
            android:background="@drawable/back1"
            android:orientation="horizontal">
            <!--留言文本-->
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="20dp"
                android:text="@string/logMessage"
                android:textAlignment="center"
                android:textColor="#3C3F41"
                android:textSize="20sp" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textAlignment="center"
                android:textColor="#3C3F41"
                android:textSize="20sp" />
        </LinearLayout>

ListView+Adapter