Thanks
2011/9/23, elliot elliot.nathan...@gmail.com:
If anyone needs an example, here you go-
public class BitmapReuseActivity extends Activity {
private Paint mPaint = new Paint();
private Rect mRect = new Rect(0,0, 123, 109);
private Canvas mCanvas = new Canvas();
private Bitmap mBitmap = Bitmap.createBitmap(124, 110,
Bitmap.Config.ARGB_);
private Resources mResources;
private static BitmapFactory.Options sBitmapOptions =
new BitmapFactory.Options();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.bitmap_reuse_listview);
mResources = getResources();
// setup bitmap reuse options.
sBitmapOptions.inBitmap = mBitmap;
sBitmapOptions.inMutable = true;
sBitmapOptions.inSampleSize = 1;
// listview of 100 images.
ListView listview =
(ListView) findViewById(R.id.listView);
listview.setAdapter(new BaseAdapter() {
public View getView(int position, View convertView,
ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new
ImageView(BitmapReuseActivity.this);
} else {
imageView = (ImageView) convertView;
}
// decode into existing bitmap.
Bitmap bitmap =
BitmapFactory.decodeResource(mResources,
R.drawable.my_image, sBitmapOptions);
if (bitmap != null) {
imageView.setImageBitmap(bitmap);
}
return imageView;
}
public long getItemId(int position) {
return 0;
}
public Object getItem(int position) {
return null;
}
public int getCount() {
return 100;
}
});
}
}
Elliot
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en