我已经使用 LazyAdapter 实现了一个自定义 ListView 来显示缩略图。最后,在我让这个 LazyAdapter 工作之后, OnItemClickListener 不显示数据而只是返回空字符串。如果我删除 ListView 的自定义 LazyAdapter 类,代码工作正常。
class LoadAllDirectories extends AsyncTask<String, String, String> {
protected String doInBackground(String... args) {
UserFunctions fn = new UserFunctions();
String id = fn.getID(getApplicationContext());
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("id", id));
JSONObject json =
jParser.makeHttpRequest(url_all_directories, "GET", params);
Log.d("All Directories: ", json.toString());
try {
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
directories = json.getJSONArray(TAG_DIRECTORIES);
for (int i = 0; i < directories.length(); i++) {
JSONObject c = directories.getJSONObject(i);
String eid = c.getString(TAG_ID);
String name = c.getString(TAG_NAME);
String image = c.getString(TAG_IMG);
HashMap<String, String> map =
new HashMap<String, String>();
map.put(TAG_ID, eid);
map.put(TAG_NAME, name);
map.put(TAG_IMG, image);
directoryList.add(map);
}
} else {
Intent i = new Intent(getApplicationContext(),
DirectoryActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
protected void onPostExecute(String file_url) {
runOnUiThread(new Runnable() {
public void run() {
ListAdapter adapter = new LazyAdapter(
DirectoryAllActivity.this, directoryList);
setListAdapter(adapter);
}
});
}
}
}
错误日志
更新:部分重复的日志已被删除。
11-19 14:17:12.612: W/System.err(16343): java.net.MalformedURLException: Protocol not found: null
11-19 14:17:12.612: W/System.err(16343): at java.net.URL.<init>(URL.java:178)
11-19 14:17:12.612: W/System.err(16343): at java.net.URL.<init>(URL.java:127)
11-19 14:17:12.612: W/System.err(16343): at com.app.android.library.ImageLoader.getBitmap(ImageLoader.java:70)
11-19 14:17:12.612: W/System.err(16343): at com.app.android.library.ImageLoader.access$0(ImageLoader.java:58)
11-19 14:17:12.612: W/System.err(16343): at com.app.android.library.ImageLoader$PhotosLoader.run(ImageLoader.java:135)
11-19 14:17:12.612: W/System.err(16343): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
11-19 14:17:12.622: W/System.err(16343): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
11-19 14:17:12.622: W/System.err(16343): at java.util.concurrent.FutureTask.run(FutureTask.java:137)
11-19 14:17:12.622: W/System.err(16343): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
11-19 14:17:12.622: W/System.err(16343): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
11-19 14:17:12.622: W/System.err(16343): at java.lang.Thread.run(Thread.java:856)
11-19 14:17:12.653: D/memalloc(16343): ion: Mapped buffer base:0x5e951000 size:3768320 offset:0 fd:55