Android EditText添加android:imeOptions=”actionSearch”设置弹出的键盘中带有搜索按钮
XML布局
android:imeOptions="actionSearch"
android:singleLine="true" //必需,否则设置actionSearch不生效
<me.yezhou.lib.ui_widget.common.ThemedEditText
android:id="@+id/et_search_input"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center"
android:background="@drawable/selector_button_rect_white_blue"
android:gravity="center_vertical"
android:hint="@string/search_input_hint"
android:imeOptions="actionSearch"
android:singleLine="true"
android:paddingLeft="30dp"
android:paddingRight="10dp"
android:textColorHint="#aaaaaa"
android:textSize="13sp"
/>
设置OnEditorActionListener监听
mEtSearchInput.setFocusable(true);
mEtSearchInput.setFocusableInTouchMode(true);
mEtSearchInput.requestFocus();
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
InputMethodManager inputManager = (InputMethodManager) mEtSearchInput.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(mEtSearchInput, 0);
}
}, 1000);
mEtSearchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
KeyBoardUtil.hideKeyBoard(mEtSearchInput);
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
}
return true;
}
});
版权声明:
作者:Joe.Ye
链接:https://www.appblog.cn/index.php/2023/03/11/android-edittext-adds-android-imeoptions-actionsearch-settings-with-search-button-on-the-pop-up-keyboard/
来源:APP全栈技术分享
文章版权归作者所有,未经允许请勿转载。
THE END
0
二维码
打赏
海报
Android EditText添加android:imeOptions=”actionSearch”设置弹出的键盘中带有搜索按钮
XML布局
android:imeOptions="actionSearch"
android:singleLine="true" //必需,否则设置actionSearch不生效
<me.yezhou.lib.ui_wi……
文章目录
关闭
共有 0 条评论