markdown 听取密钥完成,在EditText上搜索
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown 听取密钥完成,在EditText上搜索相关的知识,希望对你有一定的参考价值。
# Listen for key Done, Search on EditText
[SOURCE](https://stackoverflow.com/a/37225076/1602807)
Listen for Done, Search keypress on EditText (work for all device):
```xml
<EditText
...
android:imeOptions="actionSearch"
...
```
```java
fpc_promo_code_input_edt.setOnEditorActionListener(object: TextView.OnEditorActionListener {
override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
KeyboardUtils.hideSoftKeyboard(activity)
return true
}
return false
}
})
public static void hideSoftKeyboard(Activity activity) {
try {
final InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
final View focusView = activity.getCurrentFocus();
if (focusView != null) {
imm.hideSoftInputFromWindow(focusView.getWindowToken(), 0);
focusView.clearFocus();
} else {
if (isKeyboardShow(activity)) {
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}
}
}
} catch (Throwable e) {
e.printStackTrace();
}
}
```
Similar for key DONE.
以上是关于markdown 听取密钥完成,在EditText上搜索的主要内容,如果未能解决你的问题,请参考以下文章
Android:EditText 的 KeyListener 不接收密钥
使用 PayPal Express Checkout 听取买家的“收据确认”
markdown 在git中缓存SSH密钥密码
EditText在光标处插入字符
markdown SSH使用原密钥生成新的无密码密钥
markdown VMWare 15密钥