Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android应用程序开发中,预测文本输入(单词建议)在AutoCompleteTextView中不起作用_Android_Mobile - Fatal编程技术网

在android应用程序开发中,预测文本输入(单词建议)在AutoCompleteTextView中不起作用

在android应用程序开发中,预测文本输入(单词建议)在AutoCompleteTextView中不起作用,android,mobile,Android,Mobile,我在我的xmllike中使用了一个AutoCompleteTextView <AutoCompleteTextView android:id="@+id/myautocomplete" android:layout_width="120dp" android:layout_height="wrap_content" android:layout_alignParentTop="tru

我在我的
xml
like中使用了一个
AutoCompleteTextView

      <AutoCompleteTextView
            android:id="@+id/myautocomplete"
            android:layout_width="120dp"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:completionThreshold="1"
            android:ems="10" >
        </AutoCompleteTextView>

我希望,这个
autocompletetextview
中的输入应该像预测模式下的
editText
一样工作

当我在android中使用
editText
控件时,它会自动启用预测性文本输入(文字建议)。
要禁用它,我必须在
inputtype
属性中使用
TextNowordSuggestions

我知道,我们必须将
autocompletetextview
绑定到适配器才能获取数据,但目前该接口还没有准备好

那么有没有办法,目前的适配器可以是android默认预测文本输入或其他方式


以后我可以在下一个版本的应用程序中对其进行更改。

我尝试了很多方法,但最后我选择了
editText
作为控件来启用预测文本。
autocompletetextview
可以使用如下适配器加载建议

        AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_words);
        MyAdapter adapter = new MyAdapter(MyActivity.this, R.layout.my_row, myWords);
        textView.setAdapter(adapter);
我想替换上面代码中的
myWords
,以获得android字典建议。
但最后,我选择了
editText

设置文本后,只需执行requsetfocus即可…对我来说效果很好

search.addTextChangedListener(new CustomAutoCompleteTextChangedListener(
                this));

ArrayList<String> result = data
                        .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                search.setText(result.get(0));
                search.setSelection(search.getText().toString().length());
                search.requestFocus();
search.addTextChangedListener(新的CustomAutoCompleteTextChangedListener(
这个),;
ArrayList结果=数据
.getStringArrayListExtra(识别器意图.额外结果);
search.setText(result.get(0));
search.setSelection(search.getText().toString().length());
search.requestFocus();
这对我很有用:

    AutoCompleteTextView myAutoComplete = (AutoCompleteTextView) findViewById(R.id.myAutoComplete);
    int inputType = myAutoComplete.getInputType();
    myAutoComplete.setRawInputType(inputType &= ~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE);

@哈里,谢谢你的编辑,我会记住这些要点,下次我发帖的时候