更改Android版:数字编程 [英] Change android:digits programatically

查看:125
本文介绍了更改Android版:数字编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的布局XML

I have this in the layout xml

android:digits="0123456789."
android:inputType="phone" />

我要的是能够以编程方式改变它,能够改变来回。
在inputType下部分是细跟

What I want is to be able to change it programatically and be able to change it back and forth. The inputType part is fine with

manual_ip.setInputType(InputType.TYPE_CLASS_TEXT);

manual_ip.setInputType(InputType.TYPE_CLASS_PHONE);

但我无能与数字部分..
我需要的字符限制为0123456789还是让一切取决于复选框的状态。

But I'm clueless with digits parts.. I need to limit the chars to "0123456789." or allow everything depending on a checkbox state.

推荐答案

添加

manual_ip.setKeyListener(DigitsKeyListener.getInstance("0123456789."));

manual_ip.setInputType(InputType.TYPE_CLASS_PHONE);

和后一无所获

manual_ip.setInputType(InputType.TYPE_CLASS_TEXT);

解决我的问题!

这篇关于更改Android版:数字编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆