gpt4 book ai didi

android - 如何将复选框动态添加到 Android 布局?

转载 作者:数据小太阳 更新时间:2023-10-29 02:51:24 26 4
gpt4 key购买 nike

<分区>

我必须将 CheckBox 动态添加到我的 Activity 布局中,布局的 XML 如下`

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentSV"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:id="@+id/parentLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp" >

<RelativeLayout
android:id="@+id/feedbackRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<LinearLayout
android:id="@+id/feedbackCustomerNameLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Name : "
android:textColor="@android:color/black" />

<TextView
android:id="@+id/feedbackCustomerName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:textColor="@android:color/black" />
</LinearLayout>

<LinearLayout
android:id="@+id/feedbackPlansLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/feedbackCustomerNameLL"
android:orientation="vertical" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Plans Explained"
android:textColor="@android:color/black" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/feedbackPlansCheckBoxLL"
android:orientation="horizontal" >

<!--
Required to Add CheckBoxes Here Dynamically
-->
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</ScrollView>

`

要在评论区添加复选框。如何动态添加它们,因为我必须根据服务器发送的数据在运行时添加它们。我无法从层次结构中删除 ScrollView 或任何其他 View 。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com