使用EditText.setText(value)

时间:2019-05-09 10:03:55

标签: java android android-edittext

下面是我与rxandroid的edittext。问题是当我在搜索框中删除某些字符“ \\”和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);
                    }
                });

enter image description here

enter image description here

0 个答案:

没有答案