I have an EditText
and I want to set its inputType
depending on if the Parameter
is numeric or not:
interface Parameter {
boolean isNumeric();
}
I have this:
<EditText
...
android:inputType="@{parameter.isNumeric()? number : text}"/>
But there is an error when parsing XML. I have tried by wrapping number
and text
values in single and double (escaped) quotation marks.
How can I solve this?
The number
and text
values would be considered variables in Java context. You have to make sure to set the appropriate Java value. First you have to import InputType
in your <data>
block. Then use the relating integer values.
<EditText
android:inputType="@{parameter.isNumeric() ? InputType.TYPE_CLASS_NUMBER : InputType.TYPE_CLASS_TEXT}" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.