我有一个ListView
和一个SimpleCursorAdapter
。我的代码SimpleCursorAdapter
如下所示:
private void listenAdapterErstellen()
{
adapter = new SimpleCursorAdapter(this, R.layout.my_listlayout,
MainController.getInstance().getMyCursor(db),
new String[] {"Foo", "Test"},
new int[] {R.id.imageViewFoo, R.id.textViewTest}, 0);
adapter2.setViewBinder(new ViewBinder() {
public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
if (columnIndex == 1) {
ImageView imageView = (ImageView) view;
String Pic = cursor.getString(1);
if (Pic != null) {
File file = new File(Pic);
if (file.exists()) {
imageView.setImageBitmap(MainController.getInstance().generateBitmap(Pic, SessionActivity.this));
}
} else {
imageView.setImageResource(R.drawable.ic_launcher);
}
return true;
}
if (columnIndex == 2) {
...
}
return false;
}
});
}
问题是,MainController.getInstance().generateBitmap()
生成小位图的 my 需要很多时间。因此,加载列表需要一些时间。
如何在后台生成列表的图像并立即显示列表然后添加图片?