我正在尝试使用jsondata设置我的autocompleteTextview ...这是我的代码
JsonArrayRequest req = new JsonArrayRequest(Request.Method.GET, strUrl, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
JSONArray ja;
State1 = new ArrayList<>();
try {
String istate = null;
ja = response;
for (int i = 0; i < ja.length(); i++) {
istate = ja.getJSONObject(i).getString("Name").trim();
State1.add(istate);
ArrayAdapter adapter = new ArrayAdapter(getApplicationContext(),android.R.layout.simple_list_item_1,State1);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
state.setAdapter(adapter);
}
} catch (Exception e) {
Log.e("log_tag", "Error parsing data " + e.toString());
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
我要解析的json是......
[
{
&#34;姓名&#34;:&#34;安达曼和尼科巴群岛&#34;,
&#34;代码&#34;:1157
},
{
&#34;姓名&#34;:&#34; Andhra Pradesh&#34;,
&#34;代码&#34;:1158
},
{
&#34;姓名&#34;:&#34; Arunachal Pradesh&#34;,
&#34;代码&#34;:1159
}
我的问题是数据没有设置到autocompletetextview中......我做错了什么?