简体   繁体   English

如何弹出“?123”Android键盘

[英]How to pop-up the “?123” Android keyboard

I have an EditText which needs to process either numerical and/or alphabetical input depending on state. 我有一个EditText,需要根据状态处理数字和/或字母输入。 The user may enter either type of input in some circumstances. 在某些情况下,用户可以输入任何类型的输入。 I've only been able to pop-up the "Phone" keyboard using setInputType (InputType.TYPE_CLASS_NUMBER); 我只能使用setInputType (InputType.TYPE_CLASS_NUMBER);弹出“Phone”键盘setInputType (InputType.TYPE_CLASS_NUMBER); which works, but doesn't allow the user a way to get back to the QWERTY keyboard. 哪个有效,但不允许用户返回QWERTY键盘。 Since most of the input is indeed numerical, I would like to present the user with the ?123 keyboard most of the time. 由于大多数输入确实是数字的,我想在大多数时间向用户提供?123键盘。 They would only need to go back to the QWERTY keyboard a few times. 他们只需要几次回到QWERTY键盘。

How can I pop-up the onscreen QWERTY keyboard for alphabetical input, and then pop-up the "?123" keyboard if it's numerical? 如何弹出屏幕上的QWERTY键盘进行字母输入,然后弹出“?123”键盘,如果它是数字? I just want to save a step for the user so they don't have to hit the ?123 button on the QWERTY keyboard every time. 我只想为用户保存一个步骤,这样他们就不必每次都按下QWERTY键盘上的?123按钮。

Update : This is the keyboard I would like visible. 更新 :这是我想要的键盘。 The reason is I would like the user to easily switch between Alphabetical input and Numerical input. 原因是我希望用户在字母输入和数字输入之间轻松切换。 There is no way to switch to the QWERTY keyboard from the "number pad". 无法从“数字键盘”切换到QWERTY键盘。 In my app, numerical input is required for 90% of the input so I would like to pop it up as a convenience. 在我的应用程序中,90%的输入需要数字输入,所以我想将其弹出以方便使用。 In other words, rather than having to switch to the numerical keyboard 90% of the time, they only need to switch to QWERTY 10% of the time 换句话说,他们只需要在90%的时间内切换到数字键盘,而只需要在10%的时间内切换到QWERTY 在此输入图像描述

The call to input.setRawInputType(Configuration.KEYBOARD_QWERTY); input.setRawInputType(Configuration.KEYBOARD_QWERTY);的调用input.setRawInputType(Configuration.KEYBOARD_QWERTY); works differently on Honeycomb and later versions of Gingerbread (brings up the number pad). 在Honeycomb和更高版本的Gingerbread(带数字键盘)上的工作方式不同。 On Gingerbread 2.2.3 it works the way I want. 在Gingerbread 2.2.3上它以我想要的方式工作。 Honeycomb and 2.3.7 keyboard screengrabs are below for reference. Honeycomb和2.3.7键盘屏幕抓取在下面供参考。 I don't know why they are so different. 我不知道为什么他们如此不同。

用于Configuration.KEYBOARD_QWERTY的Honeycomb 3.2键盘Configuration.KEYBOARD_QWERTY的Gingerbread 2.3.7键盘

You can use several ways to use number keyboard. 您可以使用多种方法来使用数字键盘。 Some are listed below, 一些列在下面,

Method 1: add this attribute to your text field(EditText) 方法1:将此属性添加到您的文本字段(EditText)

android:inputType="number"

Method 2: 方法2:

use it programmatically 以编程方式使用它

edittext.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);

I believe this post answers your question. 我相信这篇文章回答了你的问题。

In short add this to your code: 简而言之,将其添加到您的代码中:

editText.setRawInputType(Configuration.KEYBOARD_QWERTY);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM