私のアプリケーションでautoCompleteTextViewを使用しています。私は都市をAutoCompleteTextViewに取り込み、サーバーから都市を取得します。私はarraylistを作成し、それに都市を設定し、autoCompleteTextViewにアダプタを設定しましたが、それを設定することはできません。なぜ私は理解できません。androidのautoCompleteTextViewにテキストを入力できません
//コードautoTextCompleteView
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,cityArray);
editCity.setAdapter(adapter);
ArrayAdapter<String> adapterArea = new ArrayAdapter<String>
(this,android.R.layout.simple_list_item_1,areaArray);
editArea.setAdapter(adapterArea);
}
//都市
private class GetAreas extends AsyncTask<String, Void, Void> {
ProgressDialog progressDialog;
String ResposeFromGetAreaApi;
@Override
protected Void doInBackground(String... params) {
//Invoke webservice
WebService wsc = new WebService();
ResposeFromGetAreaApi = wsc.GetAreas(serviceToken, "GetAreas");
return null;
}
@Override
protected void onPostExecute(Void result) {
Log.i(TAG, "GetAreas" +ResposeFromGetAreaApi);
try {
JSONObject jsonObject = new JSONObject(ResposeFromGetAreaApi);
JSONArray jsonArrayCity = jsonObject.getJSONArray("Table");
JSONArray jsonArrayArea = jsonObject.getJSONArray("Table1");
for (int i = 0; i < jsonArrayCity.length(); i++) {
modelCity = new ModelCity();
JSONObject cityObj = jsonArrayCity.getJSONObject(i);
{
String cityId = cityObj.getString("pkCityId");
modelCity.setCityId(cityId);
String cityName = cityObj.getString("CityName");
modelCity.setCityId(cityName);
}
modelCityArrayList.add(modelCity);
}
for (int j = 0; j < jsonArrayArea.length(); j++) {
modelCity = new ModelCity();
JSONObject areaObj = jsonArrayArea.getJSONObject(j);
{
String cityId = areaObj.getString("cityid");
modelCity.setAreaCityId(cityId);
String areaId = areaObj.getString("AreaId");
modelCity.setAreaId(areaId);
String areaName = areaObj.getString("AreaName");
modelCity.setAreaName(areaName);
}
modelAreaArrayList.add(modelCity);
}
}
catch (Exception e)
{
}
progressDialog.dismiss();
}