TextWatcher中的EditText clearComposingText(需要删除Android OS 4.4中的自动更正下划线)
我正试图做一些类似于本文()的事情,在用户键入时我想删除下划线。我正在制作一个富文本编辑器,不希望自动完成下划线与富文本中的下划线混淆 我有一个RichTextEditor(它是一个扩展AppCompatEditText的富文本编辑器)和一个内部RichTextEditorTextWatcher类。每次用户键入时,我都在执行TextWatcher中的EditText clearComposingText(需要删除Android OS 4.4中的自动更正下划线),android,android-edittext,android-inputtype,Android,Android Edittext,Android Inputtype,我正试图做一些类似于本文()的事情,在用户键入时我想删除下划线。我正在制作一个富文本编辑器,不希望自动完成下划线与富文本中的下划线混淆 我有一个RichTextEditor(它是一个扩展AppCompatEditText的富文本编辑器)和一个内部RichTextEditorTextWatcher类。每次用户键入时,我都在执行RichTextEditor.this.clearComposingText(),因为我不想在用户键入时看到下划线 问题:当我删除MyEditText.this.setInp
RichTextEditor.this.clearComposingText()
,因为我不想在用户键入时看到下划线
问题:当我删除MyEditText.this.setInputType(InputType.TYPE\u TEXT\u FLAG\u NO\u建议)时代码>行,每次用户键入时,整个单词建议都会作为任何输入的一部分追加,这是完全错误的
e、 当我输入“A”,然后输入“d”,然后输入“e”,我在编辑文本中得到“AAdAde”
放置RichTextEditor.this.clearComposingText()
中的code>也不起作用
我需要的是删除自动完成下划线,并保留其他行为(即,我需要在XML的inputType属性中使用textMultiline等)
我怎样才能解决这个问题
注意:自动完成下划线出现的问题仅出现在OS 4.4(三星Galaxy S4)中。android:inputType=“textnosuggests”似乎对这个版本的android没有影响,但对更高版本的android有效
public class RichTextEditor extends AppCompatEditText
{
public class RichTextEditorTextWatcher implements TextWatcher
{
@Override
public void afterTextChanged(Editable e)
{
//other implementation not shown here
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
{
RichTextEditor.this.clearComposingText();
RichTextEditor.this.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}
}
}
我在这里尝试过这些建议:但它们在三星Galaxy S4上不起作用。i、 例如,以下情况不起作用:
<com.my.app.RichTextEditor android:id="@+id/rich_text_editor"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="top"
android:imeOptions="flagNoExtractUi"
android:inputType="textMultiLine|textCapSentences|textLongMessage|textNoSuggestions"
android:isScrollContainer="true"
android:minHeight="100dp"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical" />