Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unresolved reference: string

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 = {
                    }
                )
            }
        }
    )
}
like image 296
wbk727 Avatar asked Apr 20 '26 12:04

wbk727


1 Answers

R.string should be imported with an import containing your package name such as :

import com.mycompany.myappname.R
like image 58
paul Avatar answered Apr 22 '26 02:04

paul