禁用用户输入的自动完成功能(在Java Android应用程序中)

禁用用户输入的自动完成功能(在Java Android应用程序中),java,android,autocomplete,user-input,Java,Android,Autocomplete,User Input,我想禁用手机键盘上的自动更正和自动完成单词建议 在我正在开发的应用程序中。 这是一个词汇培训师,所以我希望用户在不使用任何工具的情况下键入输入。 有没有一种方法可以用Java实现这一点?一些相关的代码片段: 用户交互: public void onClick(View view) { TextView textView = (TextView) getView().findViewById(R.id.textview); final String answ

我想禁用手机键盘上的自动更正和自动完成单词建议 在我正在开发的应用程序中。 这是一个词汇培训师,所以我希望用户在不使用任何工具的情况下键入输入。 有没有一种方法可以用Java实现这一点?一些相关的代码片段:

用户交互:

    public void onClick(View view) {
        TextView textView = (TextView) getView().findViewById(R.id.textview);
        final String answer = textView.getText().toString();
        passData(answer);
    }
以及xml:

   <EditText
        android:id="@+id/textview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toTopOf="@id/button_first"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        android:background="#CCCCCC"
        android:ems="10"
        android:inputType="textPersonName" >

        <requestFocus />
    </EditText>
附言。
我是应用程序开发新手,所以你可能会在我上面的代码中看到一些缺陷-在这种情况下,请告诉我

如果将此添加到编辑文本中,是否有效:

而不是:

android:inputType="textPersonName"
所以它变成了这样:

<EditText
    android:id="@+id/textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="@id/button_first"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:background="#CCCCCC"
    android:ems="10"
    android:inputType="text|textNoSuggestions" >

    <requestFocus />
</EditText>
程序化

文件

可以与文本及其变体组合,以指示IME不应显示任何基于词典的单词建议。对应于InputType.TYPE\u TEXT\u FLAG\u NO\u建议


谢谢,这让我知道了。就我而言,它不起作用,但我可以使用:android:inputType=textVisiblePassword
<EditText
    android:id="@+id/textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toTopOf="@id/button_first"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    android:background="#CCCCCC"
    android:ems="10"
    android:inputType="text|textNoSuggestions" >

    <requestFocus />
</EditText>
sampleEdt.inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS