将SQLite链接到Android中的自动完成文本视图?

将SQLite链接到Android中的自动完成文本视图?,android,database,autocomplete,Android,Database,Autocomplete,你好,我是Android新手。我想将我的数据库链接到自动完成文本视图。我可以看到向下滚动列表,我可以从中选择我的文本。但是我用来检索所选文本的getText()方法不起作用。我只得到我在文本框中键入的内容,因此无法从数据库中检索。请帮助我..给出了我的代码片段 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, getAllCountries());

你好,我是Android新手。我想将我的数据库链接到自动完成文本视图。我可以看到向下滚动列表,我可以从中选择我的文本。但是我用来检索所选文本的getText()方法不起作用。我只得到我在文本框中键入的内容,因此无法从数据库中检索。请帮助我..给出了我的代码片段

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.list_item, getAllCountries());
        final AutoCompleteTextView input_text = (AutoCompleteTextView)findViewById(R.id.Language);
         input_text.setAdapter(adapter);
        Linkify.addLinks(input_text, Linkify.ALL);
        Button button1=(Button)findViewById(R.id.button1);
        final Editable name1=input_text.getText();

.
.
.
public String[] getAllCountries()
    {  
         Cursor cursor = db.rawQuery("SELECT * FROM colors ",null);

                if(cursor.getCount() >0)
        {
            String[] str = new String[cursor.getCount()];
            int i = 0;

            while (cursor.moveToNext())
            {
                 str[i] = cursor.getString(cursor.getColumnIndex("English"));
                 i++;
             }
            return str;

        }
        else
        {
            return new String[] {};
        }
               }
ArrayAdapter adapter=新的ArrayAdapter(这个,R.layout.list_项,getAllCountries());
最终自动完成文本视图输入\文本=(自动完成文本视图)findViewById(R.id.Language);
输入_text.setAdapter(适配器);
Linkify.addLinks(输入文本,Linkify.ALL);
按钮button1=(按钮)findViewById(R.id.button1);
最终可编辑名称1=输入_text.getText();
.
.
.
公共字符串[]getAllCountries()
{  
Cursor Cursor=db.rawQuery(“从颜色中选择*”,null);
if(cursor.getCount()>0)
{
String[]str=新字符串[cursor.getCount()];
int i=0;
while(cursor.moveToNext())
{
str[i]=cursor.getString(cursor.getColumnIndex(“英语”);
i++;
}
返回str;
}
其他的
{
返回新字符串[]{};
}
}

我正在使用此代码创建列表尝试以下操作:

String reciv ; 
    ArrayList<String> first = new ArrayList<String>();

cursor = dbm.columnValueofTable();
            cursor.moveToFirst();
            startManagingCursor(cursor);

            for (int i = 0; i < cursor.getCount(); i++) {

                reciv = cursor.getString(cursor
                        .getColumnIndex("row1"));


                first.add(reciv);

            }

            System.out.println("LIST OF COURSE NAME  " + first);



            final String[] arrayOfStrings;

            arrayOfStrings = first.toArray(new String[first.size()]);


             AutoCompleteTextView  lst = (AutoCompleteTextView  ) dialog
                        .findViewById(R.id.dialog_list);

                lst.setAdapter(new ArrayAdapter<String>(this,
                                 android.R.layout.simple_list_item_1,android.R.id.text1,
                        arrayOfStrings));
字符串reciv;
ArrayList first=新的ArrayList();
cursor=dbm.columnValueofTable();
cursor.moveToFirst();
开始管理游标(游标);
对于(int i=0;i