0

I have an hymn book app with a search button on button click it opens a search bar page. This page goes through the data class and returns the result of the text if it is found in the list of items in the data class. The search bar produces the required result of the string in a new lazy column but it doesn't go to hymnscreen.

val viewModel: SearchViewModel = viewModel()
val songList = viewModel.list.observeAsState().value

LazyColumn {
    if (!songList.isNullOrEmpty()) {
        items(songList) { song ->
            Card(modifier = Modifier
.clickable(onClick ={
HymnActivity:class.java).apply{
                         putExtra("SONG_KEY",song)
})
.fillMaxWidth(),
shape = RoundedShape(10.dp))
{
Text(
                text = song.title,
                style = MaterialTheme.typography.h6,
                color = MaterialTheme.colors.onBackground,
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(horizontal = 20.dp, vertical = 12.dp)
                    .wrapContentWidth(Alignment.Start)
            )
        }
}
    }
}

I tried making the card in the lazy column clickable

context.startActivity(Intent(HymnActivity::class.java))

It didn't work. There are multiple Items in the list. And a view model that goes through the items in that list. That should connect to a composable and show a screen title = song.title

lyrics = song.lyrics

0 Answers0