我必須做出演示,列出從接觸烏里所有的接觸中,我已經接觸式圖像的加入我的列表視圖Scrolling的是檸慢,如下因素是後發的自定義列表視圖中添加聯繫人圖片我的代碼。緩慢的性能,因爲在我的lisview
public Bitmap getProfilepicture(Activity activity, String address)
{
Bitmap bitmap;
Uri personUri = Uri
.withAppendedPath(Phones.CONTENT_FILTER_URL, address);
Cursor phoneCursor = activity.getContentResolver().query(personUri,
PHONE_PROJECTION, null, null, null);
if (phoneCursor.moveToFirst()) {
int indexPersonId = phoneCursor.getColumnIndex(Phones.PERSON_ID);
long personId = phoneCursor.getLong(indexPersonId);
phoneCursor.close();
Uri uri = ContentUris.withAppendedId(People.CONTENT_URI, personId);
bitmap = People.loadContactPhoto(activity, uri, R.drawable.icon,
null);
return bitmap;
}
return null;
}
在方法的幫助下,我得到了我在getView方法中使用的相片照片。像
holder.imgViewLogo.setImageBitmap(getProfilepicture(activity,pos));
它的工作正常,但列表視圖性能低。
請幫我改進listview的性能。
感謝 Milind
您好,感謝性反應的我嘗試這一點,但在從互聯網上該類下載圖片在我的情況下,我從聯繫uri。 – milind
如果從互聯網上下載,從光盤或其他任何地方加載,加載圖像需要I/O,並且您只需要避免在獲取聯繫人圖像時持有UI線程(例如getView)即可。 –
我認爲這是最好的選擇,我嘗試... – milind