I'm doing a calculator. So I made my Buttons with numbers and functions. The expression that has to be calculated is in a TextField because I want users can add numbers or functions also in the middle of the expression, so with the TextField, I have the cursor. But I want to disable the Keyboard when users click on the TextField.
In XML, the solution is:
public static void disableSoftInputFromAppearing(EditText editText) {
if (Build.VERSION.SDK_INT >= 11) {
editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
editText.setTextIsSelectable(true);
} else {
editText.setRawInputType(InputType.TYPE_NULL);
editText.setFocusable(true);
}
}
##In Compose, the solution is:
CompositionLocalProvider(
LocalTextInputService provides null
) {
TextField(
value = value,
onValueChange = { value = it },
label = { Text("The Label") }
)
}
CompositionLocalProvider(
LocalTextInputService provides null
) {
TextField(
value = value,
onValueChange = { value = it },
label = { Text("The Label") }
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With