2016-11-11 68 views
1

您好我在Edittext中添加了android:inputType =“number”。我想添加“+”符号也。 我想除了“+”符号和“数字”作为输入。用户将无法添加标志。 有什么办法吗?如何删除android中的edittext中的#号输入类型

+1

'-'呢? –

+0

没有其他字符,像电话号码 – Kush

回答

0

我会通过指定

android:inputType="phone" 
android:hint="+1235554444" 

,然后通过程序检查其输入如下您需要的模板,因为手机输入型确实允许#得到用户一半。

//First ensure the input starts with "+" 
if(!phoneString[0].equals("+"){ 
    //Error 
} 

for(i = 0; i < phoneString.length() ; i++){ 
    if(phoneString[i].equals("#"){ 
     //Error 
}   

添加您可以想到的任何其他错误检查。

+0

中的+91 *****那样,但我不想在键盘中显示“#”。 – Kush

+0

@Kush我认为你将不得不编写一个自定义键盘。 – emhomm4

+0

谢谢,@艾米丽,但这是一个冗长的解决方案。 – Kush

相关问题