我试图绑定:
@Bindable
public float getRoundInEditAmount()
{
return roundInEdit.getAmount();
}
@Bindable
public void setRoundInEditAmount(float amount)
{
roundInEdit.setAmount(amount);
notifyPropertyChanged(BR.roundInEditAmount);
}
Run Code Online (Sandbox Code Playgroud)
至
<EditText
android:layout_width="100dp"
android:layout_height="50dp"
android:inputType="numberDecimal"
android:text="@={`` + weightSet.roundInEditAmount}"
></EditText>
Run Code Online (Sandbox Code Playgroud)
但是,在单击EditText时,我会看到一个文本输入而不是数字键盘。如果再次单击此EditText,则会显示数字键盘。如果该字段默认为50.0或其他值,则无法删除这些金额。虽然我可以输入文字,但它确实存在。
还有其他人遇到这种行为的原因是第一次单击时输入的文本是数字输入吗?EditText上的两种方式绑定是否也按我期望的方式工作。我已经编写了自己的Binding和InverseBinding适配器,它们的行为方式相同->第一次单击时是TextInput,然后在第二次单击时是数字键盘,但是您不能删除开头的数字。