1
안녕하세요 저는 Android가 처음입니다. 내 데이터베이스를 자동 완성 텍스트보기에 연결하려고했습니다. 스크롤 다운 목록을 볼 수 있으며 그 중에서 내 텍스트를 선택할 수 있습니다. 하지만 선택한 텍스트를 검색하는 데 사용되는 getText() 메서드가 작동하지 않습니다. 내가 텍스트 상자에 입력 한 내용 난 단지 얻고 그래서 나는 목록이 시도 만들려면이 코드를 사용하고Android에서 Textite를 자동 완성 Textite에 연결 하시겠습니까?
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[] {};
}
}