https://kotlinlang.org logo
#compose
Title
# compose
a

Alex C

11/24/2021, 4:33 AM
Hi I have a Composable looks like this:
Copy code
@Composable
fun TestClickView(
    offerList: List<String>,
    onClose: () -> Unit,
    onSelected: (String) -> Unit
) {

    Column(
        modifier = Modifier.fillMaxSize(),
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        Image(painterResource(id = R.drawable.ic_close), null, modifier = Modifier.clickable {
            Timber.i("on close clicked")
            onClose()
        })
        Spacer(modifier = Modifier.height(16.dp))
        Text("text 1")
        Text("text 2")
        LazyColumn(
            modifier = Modifier
                .padding(20.dp, 0.dp)
                .fillMaxWidth()
        ) {
            items(offerList) {
                Text(text = it, modifier = Modifier.clickable(role = Role.Button) {
                    Timber.i("on item clicked value $it")
                    onSelected(it)
                })
                Spacer(modifier = Modifier.height(16.dp))
            }
        }
    }
}
The image is clickable, and the items inside the LazyColumn is clickable, Normally it works But I find if I click other places before I click the Image or the items inside the LazyColumn, the click event is not triggered, any ideas?
🧵 3