我想更新一个从 Firebase-Realtime-Database 获取数据的 textView。 textview 更新代码嵌套在 onDataChange 函数中,该函数又嵌套在 一个 onClickListener.
db.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
// This method is called once with the initial value and again
// whenever data at this location is updated.
val value = dataSnapshot.getValue(String::class.java)
if (value != null) {
arrayList.add(value)
}
myArr.notifyDataSetChanged()
//listView.adapter=myArr
println( "Value is: $value")
if (dataSnapshot !=null) {
Thread.sleep(1000)
val name = value.toString()
println("testing $name")
textView2.text=name
}
textView2.text=name
}
请发送帮助