【问题标题】:Android Input Method Manager to get Numbers only keypadAndroid 输入法管理器仅获取数字键盘
【发布时间】:2013-01-16 13:06:24
【问题描述】:

我们使用

InputMethodManager imPharamcy = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imPharamcy .toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);

强行获取键盘。 但键盘不仅仅是数字键盘。 如何使用 inputMethod Manager 获取仅数字键盘。

在xml中我已经给出了

   android:inputType="phone"
   android:imeOptions="actionNext"              

editText 只接受数字 奇怪的是,在模拟器中出现了仅数字键盘,但在电话号码和特殊字符键盘上出现

【问题讨论】:

标签: android android-edittext


【解决方案1】:

见以下代码:

    // TYPE_CLASS_NUMBER: Class for numeric text. This displays the numbers/symbols keyboard.
editText.setInputType(InputType.TYPE_CLASS_NUMBER);

// TYPE_CLASS_PHONE: Class for a phone number. This displays the phone number keypad.
editText.setInputType(InputType.TYPE_CLASS_PHONE);

希望你明白了。

【讨论】:

  • 这不是问题所在。问题是如何使用InputMethodManager 类而不是TextView 获取仅数字键盘。我需要一个 Cordova 应用程序,其中 WebView 阻止键盘显示在焦点上,我需要使用插件强制它显示。因为它是一个 WebView,现在是一个文本框,我只需要使用 InputMethodManager,没有 TextViews 可以玩。
猜你喜欢
  • 2015-03-28
  • 2015-09-28
  • 2013-07-06
  • 1970-01-01
  • 2011-09-20
  • 1970-01-01
  • 2018-02-03
  • 2014-05-07
  • 1970-01-01
相关资源
最近更新 更多