[ad_1]
How to call functions inside AndroidView or AndroidViewBinding composable?
In the old view system if I needed to update a TextView and other things in multiple places I simply created a function like that:
private fun updateViews(value1: Int, value2: Int) = with(binding) {
timelineTextView.text = "$value1, $value2"
... A lot of other stuff
}
How is that possible when using the AndroidViewBinding Composable?
@Composable
fun MainScreen(){
AndroidViewBinding(ActivityPlayBinding::inflate) {
playButton.setOnClickListener {
updateViews(value1, value2)
}
playButton2.setOnClickListener {
updateViews(value1, value2)
}
}
}
How can I call that updateViews
function in Compose?
Simply putting the content of updateViews function where the function gets called feels really bad cause that causes a lot of duplicate code. But I cant seem to find the right way to do it…
[ad_2]