I have a ListView
and a SimpleCursorAdapter
.
My code for the SimpleCursorAdapter
looks like this:
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;
}
});
}
the problem is, that the my MainController.getInstance().generateBitmap()
which generate a small bitmap takes a lot of time. So it takes some time until the list is loaded.
How can I generate the image for the list in the background and show the list instantly and then add the pictures?