autocompletetextview 输入字母都是两遍 什么情况啊
package com.example.demo2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class MainActivity extends Activity {
private AutoCompleteTextView acTextView;
private String[] res = {"beijing1","beijing2",
"beijing3","shanghai1","shanghai2"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* 第一步:初始化控件
* 第二步:需要一个适配器
* 第三步:初始化数据源---这数据源去匹配文本框输入的内容
* 第四步:将adapter与当前AutoCompleteTextView绑定
*/
acTextView = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, res);
acTextView.setAdapter(adapter);
}
}
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<AutoCompleteTextView
android:completionThreshold="3"
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入要搜索的关键词" >
</AutoCompleteTextView>
</LinearLayout>