Android EditText 软键盘回车键变成搜索键
Android About 662 words设置
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;
}
Views: 3,205 · Posted: 2019-04-09
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...