android - 如何以编程方式打开 Android 软键盘(数字)?

标签 android android-softkeyboard programmatically-created numeric-keypad

我知道如何打开软键盘,甚至处理它的按键事件。我需要打开数字 键盘。

P.S在布局文件中使用Edittexts

这是我用来以编程方式打开键盘的代码

    if (PasscodeLockUpdated.this != null) {
    PasscodeLockUpdated.this .getWindow()
    .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);}

最佳答案

您是否以编程方式添加 EditText?如果是这样,您可以使用以下方法在 java 中更改 InputType(就像您拥有 xml 时所做的那样):

yourEditText.setInputType(InputType.TYPE_CLASS_NUMBER | **Another type if you want more than one**);

希望对您有所帮助。

关于android - 如何以编程方式打开 Android 软键盘(数字)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25254917/

相关文章:

java - Apache POI 插入图像

java - 从 ActionBar 调用新 Activity

android-layout - 不想在 Android 中按下 EditText 时(键盘出现后)隐藏 EditText View ?

java - 如何在 WebView 中禁用软键盘

android - 程序化 ImageView 和 picasso

android - 什么是 getApplicationContext() 方法?

android - 工具 :overrideLibrary not working

Android 使用键盘上的完成按钮单击按钮

uitableview - 在 Swift 中以编程方式创建一个 UITableViewController

Android,是否可以为 TextView.setGravity() 设置动画?