- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
当我的用户在虚拟 android 上按 Enter 时“用户验证条目!”键盘 我的键盘保持可见! (为什么?)
这是我的 Java 代码...
private void initTextField() {
entryUser = (EditText) findViewById(R.id.studentEntrySalary);
entryUser.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
userValidateEntry();
return true;
}
}
return true;
}
});
}
private void userValidateEntry() {
System.out.println("user validate entry!");
}
...这里是我的观点
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content">
<EditText android:id="@+id/studentEntrySalary" android:text="Foo" android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
我的虚拟设备可能有问题?
最佳答案
应该这样做:
yourEditTextHere.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (event != null&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
// NOTE: In the author's example, he uses an identifier
// called searchBar. If setting this code on your EditText
// then use v.getWindowToken() as a reference to your
// EditText is passed into this callback as a TextView
in.hideSoftInputFromWindow(searchBar
.getApplicationWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
userValidateEntry();
// Must return true here to consume event
return true;
}
return false;
}
});
关于android在按下回车键时设置隐藏键盘(在EditText中),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2434532/
我在一个网站上有一个非常简单的登录脚本,它只使用 1 个简单的密码,而且它可以满足我的需要。问题是,它仅在单击“登录”字样时有效。我需要它做的是在按下 Enter 键时也能工作。这是代码:
在我的应用程序中,我有一个全局搜索字段,用于过滤列表中的数据,列表将有多个列。从其他组件设置过滤器值(设置为输入值)它正在发生,但我必须在输入上触发手动键盘事件(输入键)操作。 我尝试使用 viewC
在我的应用程序中,我使用的是 Tinymce。这是我的问题。 场景一 1) 我有这样风格的段落 Paragraph with some content. 当我将光标放在段落末尾并按下回车键时,它会像这
我有一个包含多个下拉列表和一个文本字段以及一个按钮的表单... 当我单击按钮时,会调用一个 ajax 函数...然后 ajax 会调用一个从 mysql 数据库获取结果的 php 函数... 问题是我
我想写一个程序在每句话之后做一个处理。像这样: char letter; while(std::cin >> letter) { if(letter == '\n') { // her
我在某处找到了一个非常适合我的自动完成脚本,但有一件事我不知道如何更改。当您单击下拉列表中的某些内容时,它不会提交此字符串,您必须单击以选择该字符串,然后单击提交按钮或按回车键。我希望此下拉菜单自动完
我在几周前开始使用 Xamarin Studio,但找不到下一个问题的解决方案:创建了一个包含序列号的编辑文本。我想在按下 Enter 后运行一个函数。它工作正常,当我按 Enter 时,函数运行没有
在 Android 和 iOS 中,可以将 keyboard 的 enter/return 键更改为例如“Go”按钮(和其他选项)。 在顶部上,我们可以在两个系统上看到常规的“返回”按钮,这是您在 A
具体代码如下所述: ? 1
我知道如何使用事件来测试何时按下某个键,但在 C 语言中我从来不知道该怎么做。 我真正想要的是一个“KeyListener”,它监听Up、Down、Left 和Right 方向键。我需要它在 Linu
我使用回车键从 v-textarea 输入数据,结果如下 Hello\nWorld 在默认或 rawHtml 不工作的情况下在 v-data-table 中呈现此内容 {{ props.it
我是一名优秀的程序员,十分优秀!