0

我拿了一个AutoCompleteTextView和我xml一样的

      <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在预测模式下一样工作。

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

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

那么有什么方法吗,该适配器现在可以是android默认的预测文本输入或其他方式。

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

4

3 回答 3

0

我尝试了很多东西,但最后我将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

于 2013-03-19T11:48:21.190 回答
0

设置文本后,只需执行 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();
于 2014-11-12T18:57:02.980 回答
0

这对我有用:

    AutoCompleteTextView myAutoComplete = (AutoCompleteTextView) findViewById(R.id.myAutoComplete);
    int inputType = myAutoComplete.getInputType();
    myAutoComplete.setRawInputType(inputType &= ~EditorInfo.TYPE_TEXT_FLAG_AUTO_COMPLETE);
于 2015-07-21T14:19:11.613 回答