我有下面的屏幕,其中包含一些图像(每个可见页面 6 个)。上下滚动对我来说似乎很滞后。就像它再次渲染图像一样。向上滚动似乎比向下滚动更糟糕。
任何人都知道如何在这样的区域提高性能以创建一个漂亮的平滑滚动?
更新:图像和文本都是从我的 SQLite 数据库中检索的。该列表是使用 SimpleCursorAdapter 创建的。
private class HistoryViewBinder implements SimpleCursorAdapter.ViewBinder
{
//private int wallpaperNumberIndex;
private int timeIndex;
private int categoryIndex;
private int imageIndex;
private java.text.DateFormat dateFormat;
private java.text.DateFormat timeFormat;
private Date d = new Date();
public HistoryViewBinder(Context context, Cursor cursor)
{
dateFormat = android.text.format.DateFormat.getDateFormat(context);
timeFormat = android.text.format.DateFormat.getTimeFormat(context);
//wallpaperNumberIndex = cursor.getColumnIndexOrThrow(HistoryDatabase.KEY_WALLPAPER_NUMBER);
timeIndex = cursor.getColumnIndexOrThrow(HistoryDatabase.KEY_TIME);
categoryIndex = cursor.getColumnIndexOrThrow(HistoryDatabase.KEY_CATEGORY);
imageIndex = cursor.getColumnIndexOrThrow(HistoryDatabase.KEY_IMAGE);
}
@Override
public boolean setViewValue(View view, Cursor cursor, int columnIndex)
{
Log.d(TAG, "setViewValue");
if (view instanceof TextView)
{
Log.d(TAG, "TextView");
TextView tv = (TextView) view;
if (columnIndex == timeIndex)
{
Log.d(TAG, "timeIndex");
d.setTime(cursor.getLong(columnIndex));
tv.setText(timeFormat.format(d) + " " + dateFormat.format(d));
return true;
}
else if (columnIndex == categoryIndex)
{
Log.d(TAG, "categoryIndex");
tv.setText(cursor.getString(columnIndex));
return true;
}
}
else if (view instanceof ImageView)
{
Log.d(TAG, "ImageView");
ImageView iv = (ImageView) view;
if (columnIndex == imageIndex)
{
Log.d(TAG, "imageIndex");
byte[] image = cursor.getBlob(columnIndex);
Bitmap bitmapImage = BitmapFactory.decodeByteArray(image, 0, image.length);
iv.setImageBitmap(bitmapImage);
return true;
}
}
return false;
}
}