这就是我填充适配器的方式:
class Ajax5 extends AsyncTask<String, String, String> {// JSON STARTS HERE
protected ArrayList<NameValuePair> parameters;
ArrayList<HashMap<String, String>> pickpinn;
JSONObject json;
public Ajax5() {
super();
parameters = new ArrayList<NameValuePair>();
}
@Override
protected void onPreExecute() {
super.onPreExecute();
pickpinn = new ArrayList<HashMap<String, String>>();
}
protected String doInBackground(String... args) {
Spots_tab1_json sh = new Spots_tab1_json();
String jsonStr = sh.makeServiceCall("myaddress/getPredicts.php", Spots_tab1_json.GET);
if (jsonStr != null) {
try {
json = new JSONObject(jsonStr);
} catch (JSONException e1) {
Log.v("this", e1.getMessage());
}
}
return null;
}
protected void onPostExecute(String file_url) {
try {
JSONArray jArray = json.getJSONArray("contacts");
for (int i = 0; i < jArray.length(); i++) {
HashMap<String, String> valuePairs = new HashMap<String, String>();
JSONObject tempObj = jArray.getJSONObject(i);
valuePairs.put("id", tempObj.getString("id"));
valuePairs.put("name", tempObj.getString("name"));
pickpinn.add(valuePairs);
}
if (pickpinn != null && pickpinn.size() > 0) {
SimpleAdapter sp5_adapter = new SimpleAdapter(FistActiivty.this, pickpinn,
R.layout.newcardialogitme, new String[] { "names" }, new int[] { R.id.textView1 });
etSearch.setAdapter(sp5_adapter);
etSearch.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View v, int arg2, long arg3) {
}
});
sp5_adapter.notifyDataSetChanged();
}
} catch (Exception e) {
Log.v("this", e.getMessage());
e.printStackTrace();
}
}
}
这是autocompletetextview的图像,如您所见,它返回行但不显示值:
这是textview xml文件:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:padding="9dp"
android:textColor="#000000"
android:textSize="@dimen/newcardialogitem" >
</TextView>
你可以帮助我,为什么它不显示文本?
谢谢