java - 使用 EditText.setText(value) 时停止刷新我的键盘
问题描述
下面是我与 rxandroid 的编辑文本。问题是当我在搜索框中删除某些字符'\\'和setText时我的键盘刷新。所以它让我的键盘切换回字母(图 1),而我想保留数字和特殊字符(图 2)。有没有办法在不刷新页面的情况下设置 EditText 文本?
SearchEditText = RxTextView.textChanges(searchbox)
.map(CharSequence::toString)
.debounce(2, TimeUnit.SECONDS)
.distinctUntilChanged()
//.observeOn(Schedulers.computation()) // can test without this
//.switchMap(RegrexAndActualNumberHelper::TrySearchValidation) // can test without this
.observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> {
// searchbox.setText(result); // settext make the page refresh and reset the keyboard to alphabets
searchbox.setSelection(searchbox.getText().length()); // move the cursor b to end of the line.
if( !result.isEmpty() ){
getInventoryItems(view, searchbox, recycler);
}
});
解决方案
推荐阅读
- akka.net - 向 Akka.Net ConsistentHashingPool routees 广播消息的最佳方式是什么?
- sql-server - INNER select 语句中的数据类型定义为 MONEY,但随后在外部 SELECT 语句中更改为 int 数据类型
- css - 如何调整内部元素的宽度以使其自然换行?
- apache-spark - 通过 Spark 在 S3 前缀分区中回滚写入失败
- javascript - 如何用两个元素替换一个 DOM 元素 - vanilla js
- graph - 有没有办法使用图表来描述 Power Bi 表中记录子集的状态?
- android - Admob 未显示广告 - 此日志告诉我什么?
- git - git 对象存储在磁盘上的完整位置列表是什么?
- python - 您是否必须在 MS Azure VM 上运行的 python 代码中包含多处理?
- android - 反对在 Android 上直接使用 javax.crypto