我在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
一样工作。
当我在android中使用editText
控件时,它会自动启用预测文本输入(单词建议)
要禁用它,我必须在TextNowordSuggestions
属性中使用inputtype
。
我知道,我们必须将autocompletetextview
绑定到适配器以获取数据,但是现在接口还没有准备好。
所以有一些方法,现在适配器可以是android默认预测文本输入或其他方式。
我可以稍后在我的下一个应用版本中进行更改。
答案 0 :(得分: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
。
答案 1 :(得分:0)
设置文本后,只需执行requestfocus ...它对我来说很好..
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();
答案 2 :(得分:0)
这对我有用:
<cfldap>