chroza
01/23/2024, 6:31 PMMainActivity
is blank?
• the data I need to show, is in the NatureCardsScreen
class in the same project, and my MainActivity
just calls this screen.
• `NatureCardsScreen`'s Previews are working perfectly fine, data is there and visible within this class.
• if I put all the code from NatureCardsScreen
in MainActivity
, it's not blank anymore and I can see everything.
But when I separate NatureCardsScreen
from MainActivity
, the activity is blank. What am I missing? (will post MainActivity
code in the thread)chroza
01/23/2024, 6:31 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ThirtyDaysOfNatureTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
ThirtyDaysOfNature()
}
}
}
}
}
@Composable
fun ThirtyDaysOfNature() {
NatureCardsScreen()
}
chroza
01/23/2024, 6:32 PMNatureCardsScreen()
shows all the previews on its own, is there something I have to include in the MainActivity
in this case?Travis Griggs
01/23/2024, 7:33 PMchroza
01/23/2024, 7:43 PMNatureCardsScreen
for the sake of testing, maybe there is anything wrong/suspicious here that I'm not seeing? Here is the code:
class NatureCardsScreen {
@Composable
fun NatureCard(modifier: Modifier = Modifier) {
ElevatedCard(
elevation = CardDefaults.cardElevation(10.dp),
modifier = Modifier.background(Color.Red)
) {
Column(
modifier = modifier.padding(16.dp),
) {
Text(text = "Some text")
Text(text = "Some more text")
}
}
}
@Preview(showBackground = true)
@Composable
fun NatureCardPreview() {
ThirtyDaysOfNatureTheme {
NatureCard()
}
}
}
Mike
01/23/2024, 8:09 PMchroza
01/23/2024, 8:20 PMMainActivity
👍