I am trying to load plurals in the error text in my TextInputEditText
:
<android.support.design.widget.TextInputEditText
android:id="@+id/et_subject_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textCapWords"
android:lines="1"
android:maxLines="1"
android:singleLine="true"
android:text="@{ model.name }"
android:hint="@string/hint_name"
app:validateRegex='@{"^*\\S{2}.*$"}'
app:validateRegexMessage="@{@plurals/error_too_short(model.minNameLength)}"/>
But in my app it shows my string but with %d
instead of model.minNameLength
value. The app:validateRegex
is an attribute is defined by Data Binding Validator library.
My plurals:
<plurals name="error_too_short">
<item quantity="one" >Too short, enter at least %d visible character.</item>
<item quantity="other" >Too short, enter at least %d visible characters.</item>
</plurals>
What's wrong? Or has it a some another way to show plurals in xml?
P.S. I use a data binding engine V2 if it's important.
It should look like this:
<plurals name="recent_messages">
<item quantity="zero">No Recent Messages</item>
<item quantity="one">1 Recent Message</item>
<item quantity="other">%1$d Recent Messages</item>
</plurals>
mContext.getResources().getQuantityString(R.plurals.recent_messages, count, count);