When creating a reusable top app bar, string
became unresolved. Is there additional code that is needed to fix this?
Unresolved reference: string
@Composable
fun MyTopAppBar(
title: String,
) {
var showMenu by remember { mutableStateOf(false) }
LargeTopAppBar(
title = {
Text(
text = title,
style = MaterialTheme.typography.headlineMedium,
textAlign = TextAlign.Start,
maxLines = 1,
)
},
actions = {
IconButton(onClick = { showMenu = !showMenu }) {
Icon(
imageVector = Icons.Default.MoreVert,
contentDescription = stringResource(R.string.more_options)
)
}
DropdownMenu(
expanded = showMenu,
onDismissRequest = { showMenu = false }
) {
DropdownMenuItem(
text = { Text(text = stringResource(R.string.settings)) },
onClick = {
}
)
}
}
)
}
CodePudding user response:
R.string should be imported with an import containing your package name such as :
import com.mycompany.myappname.R