Android EditText 软键盘回车键变成搜索键
Android 大约 662 字设置
xml
中设置EditText
的属性,并且设置inputType
android:inputType="text"
android:imeOptions="actionSearch"
设置监听,实现TextView.OnEditorActionListener
接口
mSearch.setOnEditorActionListener(this);
实现onEditorAction
方法
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.hideSoftInputFromWindow(v.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
getInfoFromNet();
}
return true;
}
return false;
}
阅读 2928 · 发布于 2019-04-09
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓
昵称:
随便看看
换一批
-
macOS 访达中打开 usr 或隐藏目录阅读 551
-
Docker 部署 Excalidraw阅读 3094
-
Elasticsearch 监控运行状态阅读 2467
-
PostgreSQL 判断条件 is not null 和 != null 的区别阅读 240
-
IDEA macOS 合并的窗口间切换阅读 1371
-
算法:数组中的第 K 个最大元素阅读 1174
-
Spring Boot 不引入模板引擎加载 HTML 网页等资源阅读 1888
-
Rust Cargo 相关命令阅读 606
-
Linux grep/zgrep 提示 Binary file matches阅读 3764
-
Spring Boot 获取所有 SpringMVC Controller 路径阅读 2743