android 设置文本框输入为数字

设置文本框只接受数字
editText.setKeyListener(new NumberKeyListener()
{
@Override
protected char[] getAcceptedChars()
{
return new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
}
public int getInputType()
{
return android.text.InputType.TYPE_CLASS_PHONE;
}
});

XML文件的设置为:

android:numeric="integer" 

原文地址:https://www.cnblogs.com/beyond1008/p/2501167.html