Does anybody of what’s the alternative of this in ...
# compose
d
Does anybody of what’s the alternative of this in Jetpack compose? https://stackoverflow.com/a/74828216/3486601
r
Did u try with keyboardoptions?
In compose
d
Yes I have already tried it but it doesn’t work. There seems to be no alternative for
textNoSuggestions
there is parameter called
autoCorrect
in
KeyBoardOptions
but it doesn’t seem like it’s what I expected it to be.
Also from the documentation
autoCorrect
- informs the keyboard whether to enable auto correct. Only applicable to text based
KeyboardTypes
such as
KeyboardType.Email
,
KeyboardType.Uri
. It will not be applied to
KeyboardTypes
such as
KeyboardType.Number
And I’m using
KeyboardType.Number
r
You can still use xml edittext in compose using androidview
d
Just for such a simple thing, I don’t want to change my view. But I have found a workaround for now.
Copy code
var value by remember { mutableStateOf("") }
var oldValueCount by remember { mutableStateOf(0) }

TextField(
    value = value,
    onValueChange = { newValue ->
        if ((newValue.count() - oldValueCount) <= 1) {
            value = newValue
            oldValueCount = newValue.count()
        }
    }
)
With the above workaround, even if the user clicks on suggested text to be pasted from Keyboard,
TextField
won’t get updated
r
Great 👍