to simply show text, in addition to allowing it to be editable?
That is, instead of doing this:
Copy code
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }
if (isEditing) {
BasicTextField(...)
} else {
Text(...)
}
You do this:
Copy code
var isEditing by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("some editable text") }
BasicTextField(
...
value = text,
enabled = isEditing,
decorationBox = { innerTextField ->
Surface(
...
// A visual cue to show that the field is being edited
border = if (isEditing) BorderStroke(...) else null
) {
innerTextField()
}
}
)
đź§µ 2
c
Csaba Kozák
10/18/2021, 8:11 AM
What about using the
readOnly
parameter?
c
Chris Fillmore
10/18/2021, 4:54 PM
Hmm yes this seems to be the better option, thanks for the idea
Chris Fillmore
10/18/2021, 4:55 PM
Can I ask, is it preferable to put code blocks in the thread? Is that what the “thread” reaction means