AutoCompleteTextView Android不';行不通

AutoCompleteTextView Android不';行不通,android,autocompletetextview,Android,Autocompletetextview,我试图实现一个AutoCompleteTextView,该视图由Sqlite数据库中可用的选项填充 我使用以下代码创建了一个Get方法: //Get Concelhos to Search Autocomplete public ArrayList<String> getListConcelhos() { ArrayList<String> listaConcelhos = new ArrayList<>(); dbase = thi

我试图实现一个
AutoCompleteTextView
,该视图由Sqlite数据库中可用的选项填充

我使用以下代码创建了一个Get方法:

    //Get Concelhos to Search Autocomplete
public ArrayList<String> getListConcelhos() {
    ArrayList<String> listaConcelhos = new ArrayList<>();

    dbase = this.getReadableDatabase();

    Cursor cursor = dbase.rawQuery("SELECT DISTINCT CONCELHO FROM " + TABLE_NAME, null);
    //cursor.moveToFirst();

    while (cursor.moveToNext()) {
        String value = cursor.getString(
                cursor.getColumnIndex("CONCELHO"));

        listaConcelhos.add(new String(value));  // TENTAR
    }


    return listaConcelhos;

}
但不起作用,下拉列表中没有选项。 我做了一个日志来验证get方法是否返回了信息,以及信息是否正确返回

Log.e("LOG: ", listaConcelhos.toString());
我尝试了另一个例子,使用了硬编码字符串[],这样可以工作:

String[] concelhos = {"Concelho 1", "Concelho2"};

text=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextViewConcelhos);
ArrayAdapter adapter = new
ArrayAdapter(this,android.R.layout.simple_list_item_1,concelhos);
text.setAdapter(adapter);
text.setThreshold(1);
为什么我最初使用get方法的实现不起作用?使用硬编码字符串[]工作

你能帮我解决这个问题吗


谢谢

您检查过生成的列表是否为空吗?是的,我使用Log.e(“Log:,listaConcelhos.toString())检查过它;并显示从数据库加载的所有信息。为什么在listaConcelhos.add(新字符串(值))中添加新字符串(值);为什么不只向列表中添加值?显示返回的日志日志返回此日志:“日志:Concelho 1、Concelho 2、Concelho 3,并且与从数据库列中选择的信息一致
String[] concelhos = {"Concelho 1", "Concelho2"};

text=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextViewConcelhos);
ArrayAdapter adapter = new
ArrayAdapter(this,android.R.layout.simple_list_item_1,concelhos);
text.setAdapter(adapter);
text.setThreshold(1);