解决方案:
所以,最后我找到了解决我的问题的方法。不是Bitmaps
在我getAllContact()
打电话时得到所有的,而是在用户按下一行时加载位图ListView
这是setOnClickListener
我在 CustomAdapter 中的方法中所做的ListView
String PCN = cases.get(position).getCaseNumber();
int tempPCN = Integer.valueOf(PCN);
tempBitMapArray = dbHandler.getFinger(tempPCN);
Bitmap left = tempBitMapArray[0];
Bitmap right = tempBitMapArray[1];
ByteArrayOutputStream bs1 = new ByteArrayOutputStream();
left.compress(Bitmap.CompressFormat.PNG, 100, bs1);
ByteArrayOutputStream bs2 = new ByteArrayOutputStream();
right.compress(Bitmap.CompressFormat.PNG, 100, bs2);
和getFinger(...)
方法:
public Bitmap[] getFinger(int pcn) {
Bitmap[] fingers = new Bitmap[2];
String SQLQUERY = "SELECT " + RIGHTFINGER + ", " + LEFTFINGER +" FROM " + TABLE_CASES + " WHERE " + KEY_ID + "=" + pcn + ";";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(SQLQUERY, null);
BitmapFactory.Options options=new BitmapFactory.Options();
options.inSampleSize = 2;
if (cursor.moveToFirst()) {
do {
byte[] blob1 = cursor.getBlob(cursor.getColumnIndexOrThrow("leftFinger"));
Bitmap bmp1 = BitmapFactory.decodeByteArray(blob1, 0, blob1.length, options);
byte[] blob2 = cursor.getBlob(cursor.getColumnIndexOrThrow("rightFinger"));
Bitmap bmp2 = BitmapFactory.decodeByteArray(blob2, 0, blob2.length, options);
fingers[0] = bmp1;
fingers[1] = bmp2;
return fingers;
} while(cursor.moveToNext());
}
return null;
}
我希望这个例子能给其他人一个正确的方向。