'Kotlin Firebase Realtime DB EventListener Question
I have a question while using the Firebase real time DB in Kotlin. Currently, we are getting the seebar value from DB. This code sends the value to the text view normally.
SeekBardata.addValueEventListener(object :ValueEventListener{
override fun onDataChange(snapshot: DataSnapshot) {
seekbarval=snapshot.getValue().toString().toInt()
binding.textView2.text = seekbarval.toString()
}
override fun onCancelled(error: DatabaseError) {
}
})
However, the code below cannot send the seebar value to the text view.
SeekBardata.addValueEventListener(object :ValueEventListener{
override fun onDataChange(snapshot: DataSnapshot) {
seekbarval=snapshot.getValue().toString().toInt()
}
override fun onCancelled(error: DatabaseError) {
}
})
with(binding) {
textView2.text = seekbarval.toString()
}
I don't know the cause. I'd really appreciate it if you could tell me the solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
