Swa*_*yam 4 android buttonclick numeric-keypad
在我的应用程序中,我试图在用户单击按钮时显示数字小键盘.
单击该按钮时,我使用requestFocus()将焦点移动到布局中的EditText,然后我需要显示数字小键盘,以便用户可以键入值.
值始终为数字,因此我只需要显示数字键盘.
我厌倦了在我的按钮的onClick()方法中使用它,但它不起作用.
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
Run Code Online (Sandbox Code Playgroud)
请为我提供任何解决方案.
此外,我的应用程序是支持4.0.3的Android平板电脑.
这是EditText属性中的一个
android:inputType="phone" (This will displayed phone numeric keypad)
Run Code Online (Sandbox Code Playgroud)
要么
android:inputType="number" (This will displayed numeric keypad)
Run Code Online (Sandbox Code Playgroud)
现在,您必须在Button的Click上设置Focus on EditText.
就像是,
edtNumber = (EditText) findViewById(R.id.number);
// Button's onClick....
@Override
public void onClick(DialogInterface dialog, int which)
{
edtNumber.requestFocus();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5656 次 |
| 最近记录: |