[英]Limit the number of text in edittext to 13 digits android
How can I ensure that the text entered on this edittext is nothing but 13digits. 如何确保在此edittext上输入的文本不过是13位数字。 This is my attempt but the user can enter 5 digits but I want it 13 digits
这是我的尝试,但用户可以输入5位数字,但我希望输入13位数字
<EditText
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:maxLength="13"
android:layout_below="@+id/TextView01"
android:layout_centerHorizontal="true"
android:ems="10"/>
updated codes 更新代码
final EditText phone = (EditText)findViewById(R.id.phone);
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(11);
phone.setFilters(filterArray);
if(Double.parseDouble(phone.getText().toString()) > 11)
{
//the above if text always fails
}
I don't know exactly what you want to do, but maybe you could try one of the following: 我不完全知道您想做什么,但是也许您可以尝试以下方法之一:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.