私はあなたにこれだけのように見えるあなたのタスクのためだけの一般的な概要を与えるでしょう、
public List<String> suggest; //List of suggestions
autoComplete.addTextChangedListener(new TextWatcher(){
public void afterTextChanged(Editable editable) {
// TODO Auto-generated method stub
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
public void onTextChanged(CharSequence s, int start, int before, int count) {
String newText = s.toString();
new getJson().execute(newText);
}
});
getJson AsyncTask - >サーバーから新しい値を取得するための
class getJson extends AsyncTask<String,String,String>{
@Override
protected String doInBackground(String... key) {
String newText = key[0];
newText = newText.trim();
newText = newText.replace(" ", "+");
try{
//Codes to retrieve the data for suggestions
suggest = new ArrayList<String>();
JSONArray jArray = new JSONArray(data);
for(loop the array){
String SuggestKey = //retrieve values by iterating;
suggest.add(SuggestKey);
}
}catch(Exception e){
Log.w("Error", e.getMessage());
}
//Populate suggestions
runOnUiThread(new Runnable(){
public void run(){
aAdapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.item,suggest);
autoComplete.setAdapter(aAdapter);
aAdapter.notifyDataSetChanged();
}
});
return null;
}
0123詳細情報についてはをご覧ください。
基本キーをJSONファイル(テキストファイル)にダウンロードし、ローカルのSQLiteデータベースにデータを保存しない場合は、それを検索できます。 –