- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有几个 EditText,我已将 imeOptions 设置为 actionDone。当我使用 Android 2.1 或 Android 2.2 在模拟器中运行我的应用程序时,虚拟键盘上的回车键变为“完成”。
但是,(而且我还没有在模拟器中测试过),当我在运行 Android 2.3(直接 2.3,Nexus S)的手机上运行我的应用程序时,虚拟键盘上的回车键仍然是返回按钮并按下它会在 EditText 中输入一个换行符。
如何让虚拟键盘上的返回键在 Android 2.3 中说出和表现得像“完成”?
最佳答案
我已经按照下面的方式实现了,它对我来说效果很好。尝试一下它可能会对您有所帮助。
EditText m_etDone = (EditText) findViewById(R.id.am_etDone);
EditText m_etSearch = (EditText) findViewById(R.id.am_etSearch);
m_etDone.setOnEditorActionListener(new DoneOnEditorActionListener());
m_etSearch.setOnEditorActionListener(new DoneOnEditorActionListener());
class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView p_v, int p_actionId, KeyEvent p_event) {
if (p_actionId == EditorInfo.IME_ACTION_DONE)
{
InputMethodManager m_imm = (InputMethodManager)p_v.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE);
m_imm.hideSoftInputFromWindow(p_v.getWindowToken(), 0);
return true;
}
else if(p_actionId == EditorInfo.IME_ACTION_SEARCH)
{
Toast.makeText(getApplicationContext(),"Search Text",Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
}
布局文件:
<EditText
android:id="@+id/am_etDone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter some text"
android:imeOptions="actionNext"
android:singleLine="true"
android:imeActionLabel="Done"/>
<EditText
android:id="@+id/am_etSearch"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Enter search text"
android:imeOptions="actionSearch"
android:singleLine="true"
android:layout_below="@+id/am_etDone"
android:imeActionLabel="Search"/>
关于android - imeOptions actionDone with Android 2.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7534631/
我正在尝试获取 Android 应用程序的登录屏幕,到目前为止这是我的代码:
我有一个编辑文本。它包含属性数字和 imeOptions (actionDone)。 同时使用 digit && imeOptions 属性时未找到 actionDone(Softkeyword 中
我有几个 EditText,我已将 imeOptions 设置为 actionDone。当我使用 Android 2.1 或 Android 2.2 在模拟器中运行我的应用程序时,虚拟键盘上的回车键变
我需要为我的 edittext 设置 actiondone 而不设置单行选项(我需要多行输入)。我该怎么做? 这是代码: 最佳答案 这对我有用: 关于android - 没有 singl
我有一个奇怪的错误。 我有一个 EditText,我正在使用 TextWatcher 执行搜索,当我键入 3 个及以上的字母时,我正在执行搜索。 直到最近我才有一个普通的 EditText,我想在我的
标题中的问题。 我试过类似的方法: onView(withId(R.id.search_edit_text)) .perform(typeText("some"), p
我对 EditText 的 inputType 并不陌生,但现在我在设置 android:inputType="textPassword" 除了使用 android:imeOptions="actio
我有这个 xml editText 它运行良好,完成按钮似乎隐藏了键盘并完成了输入 session 。 但是,当我希望它通过像这样添加 android:digits 来限制为字母字符时: 然后,a
我在 Android 2.3 中使用 EditText 时遇到问题。 我有一个用 android:imeOptions="actionDone" 属性定义的 EditText 但是当我通过虚拟键盘书写
我有用于在消息(电子邮件、短信)上输入内容的 EditText。我希望在单击 ActionDone 按钮时立即发布消息。我为此使用以下代码: message.setOnEditorActionList
如何同时设置这些选项: android:minLines="3" android:inputType="textMultiLine" android:imeOptions="actionDone" 似
我是一名优秀的程序员,十分优秀!