如何将MutableLiveData <Boolean>数据绑定到复选框

问题描述

我有一个 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/85.0.4183.102 Safari/537.36' } link = 'https://www.amazon.in/gp/your-account/order-history?opt=ab&digitalOrders=1&unifiedOrders=1&returnTo=&orderFilter=year-2020' data = requests.get(link,headers = headers) soup = BeautifulSoup(data.text,'lxml') product = soup.find('div',class_="a-box-group a-spacing-base order") print(product) 字段,我想用复选框应用两种方式的数据绑定。

Xml文件:

MutableLiveData<Boolean>

kotlin代码是

<?xml version="1.0" encoding="utf-8"?>
<layout>

    <data>

        <variable
            name="checked"
            type="Boolean"/>
    </data>

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <TextView
            android:id="@+id/layout_textview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <CheckBox
            android:id="@+id/layout_checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="@={checked}" />

    </LinearLayout>
</layout> 

在扩展基本适配器的类内完成。 override fun getView(p0: Int,p1: View?,p2: ViewGroup?): View { val layoutInflater : LayoutInflater = LayoutInflater.from(p2!!.context) val binding = RadioViewLayoutBinding.(layoutInflater,p2,false) binding.checked = required.checkedItems[p0].value if (p2 != null) binding.lifecycleOwner = p2!!.context as LifecycleOwner return binding.root } CheckedItems,我也尝试将其声明为ArrayList(MutableLiveData(Boolean)),但没有用。

对于ArrayList(Boolean)中的每个元素,我都在checkedItems中创建了一行,即使我修改了复选框,相应的listView元素也不会更新。我在做什么错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...