Android的显示数字键盘上的按钮单击 [英] Android Display Numeric Keypad on Button Click

查看:435
本文介绍了Android的显示数字键盘上的按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序,我想,当用户点击一个按钮,显示数字键盘。

In my application, I am trying to display the numeric keypad when the user clicks on a button.

在单击该按钮,我使用requestFocus的()和next我需要显示的数字小键盘,使用户可以键入数值我的布局重点转移到EditText上..

When the button is clicked, I shift the focus to the EditText in my layout using requestFocus() and next I need to display the numeric keypad so that the user can type in the values..

该值将始终是数字,所以我需要只显示了数字小键盘。

The values will always be numeric and hence I need to show only the numeric keypad.

我厌倦了使用这里面我的按钮的onClick()方法,但它不能正常工作。

I tired using this inside my button's onClick() method but it does not work.

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

请为我提供任何解决这个。

Please provide me with any solution to this.

另外,我的应用程序是一个Android平板电脑支持4.0.3。

Also, my application is for an Android tablet supporting 4.0.3.

推荐答案

这一个在你的的EditText 属性

android:inputType="phone" (This will displayed phone numeric keypad)

android:inputType="number" (This will displayed numeric keypad)

现在,你只将焦点设置在您的EditText上按钮的点击。

Now, you have to just set Focus on your EditText on Button's click..

像,

edtNumber = (EditText) findViewById(R.id.number);

// Button's onClick....
@Override
 public void onClick(DialogInterface dialog, int which)
  {
    edtNumber.requestFocus();
  }

这篇关于Android的显示数字键盘上的按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆