【发布时间】:2020-12-25 01:11:26
【问题描述】:
我正在尝试将两个商店添加到一个可变列表中,如下所示:
private var _shopList = MutableLiveData<List<Shop>>()
var shopList: LiveData<List<Shop>> = ()
get() = _shopList
// This function will get the arrayList items
fun getArrayList(): MutableLiveData<List<Shop>>
{
// Here we need to get the data
val shop1 = Shop("AOB", "Lat and Long","LA")
val shop2 = Shop("Peach", "Lat and Long","Vegas")
_shopList.add(shop1)
_shopList.add(shop2)
return _shopList
}
但是它说 add 函数没有被引用?
【问题讨论】:
标签: android kotlin mutablelivedata