How to call functions inside AndroidView or Androi...
# compose
a
How to call functions inside AndroidView or AndroidViewBinding composable? In the old view system if I needed to update multiple views in multiple places, I simply created a function for that:
Copy code
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?
Copy code
@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…
m
You don't update views in compose. Instead you should update your state and compose will recompose the views that use that state.
🤝 1