布局里写 android:digits="1234567890" 还要加一个条件: InputType.TYPE_CLASS_NUMBER 否则将不起作用 可以用代码也可以在布局里写 转载于:https://my.oschina.net/u/2299380/blog/868420