android 文本框输入法控制

  在android开发中,必不可少的会使用到文本框(EditText)来进行数据录入,也就会需要对输入法进行一些控制。
android:inputType     :指定输入法的类型,int类型,可以用|选择多个。取值可以参考:android.text.InputType类。
                                     取值包括 text, textUri, phone,number,等。
android:imeOptions    :指定输入法窗口中的回车键的功能,可选值为normal,actionUnspecified,actionNone,actionGo,actionSearch,actionSend,actionNext,actionDone。

                                     部分输入法对此的支持可能不够好。

  1. 下面的LAYOUT定义文件举了一些例子说明inputType和imeOptions的使用。  
  2. <EditText android:id="@+id/textNormal"  
  3.   
  4. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  5.   
  6. android:hint="Normal text"  
  7.   
  8. android:inputType="text"  
  9.   
  10. android:imeOptions="actionNext"  
  11. />  
  12. <EditText android:id="@+id/textInteger"  
  13.   
  14. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  15.   
  16. android:hint="Integer only"  
  17.   
  18. android:inputType="number"  
  19.   
  20. android:imeOptions="actionNext"  
  21. />  
  22. <EditText android:id="@+id/textDecimal"  
  23.   
  24. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  25.   
  26. android:hint="Decimal only"  
  27.   
  28. android:inputType="numberDecimal"  
  29.   
  30. android:imeOptions="actionNext"  
  31. />  
  32. <EditText android:id="@+id/textPhone"  
  33.   
  34. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  35.   
  36. android:hint="Phone number"  
  37.   
  38. android:inputType="phone"  
  39.   
  40. android:imeOptions="actionNext"  
  41. />  
  42. <EditText android:id="@+id/textEmail"  
  43.   
  44. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  45.   
  46. android:hint="Email"  
  47.   
  48. android:inputType="textEmailAddress"  
  49.   
  50. android:imeOptions="actionSend"  
  51. />  
  52. <EditText android:id="@+id/textSite"   
  53. android:layout_width="fill_parent" android:layout_height="wrap_content"  
  54.   
  55. android:hint="Web Site"  
  56.   
  57. android:inputType="textUri"  
  58.   
  59. android:imeOptions="actionDone"/>  


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值