Android - B

ʱ䣺 2013-04-02 12:35:26 ߣ rapoo

Android - 髤BitmapUI为ABitmap?
I为ABitmap BitmapFactory.decode* 讨载大举Q该UI为使?费颼Q载?费读?庤CPU{?UI为ANR衺Android伺?好?/div>
Q以使 AsyncTask UI为A?Q好并Q迸
使AsyncTask AsyncTask 好UI为夿丧亻任I为?lAsyncTask ?使步d?

ListView?a href="http://www.android-doc.com/reference/android/widget/GridView.html" style="font-family:'courier new',courier,monospace; font-size:14px; font-weight:bold; line-height:21px; color:rgb(37,138,175); text-decoration:initial">GridView 常襹塻lAsyncTask ?使产A?亰罿Q迱伩@孽姦?span style="background-color:rgb(249,249,249); color:rgb(34,34,34); font-family:Roboto,sans-serif; font-size:14px; line-height:19px"> AsyncTask 诹已A?孹@?弥d衡庹丳衡L两Q迸颽讽?
q颻以?a href="http://www.android-doc.com/reference/android/widget/ImageView.html" style="font-family:'courier new',courier,monospace; font-size:14px; font-weight:bold; line-height:21px; background-color:rgb(249,249,249); color:rgb(37,138,175); text-decoration:initial">ImageView 对象??使?a href="http://www.android-doc.com/reference/android/os/AsyncTask.html" style="font-family:'courier new',courier,monospace; font-size:14px; font-weight:bold; line-height:21px; color:rgb(37,138,175); text-decoration:initial">AsyncTask W以L任?/div>
??a href="http://www.android-doc.com/reference/android/graphics/drawable/Drawable.html" style="font-family:'courier new',courier,monospace; font-size:14px; font-weight:bold; line-height:21px; color:rgb(37,138,175); text-decoration:initial">Drawable 孱对syncTask (迸AsyncTask 丨Drawable ?迧以?a href="http://www.android-doc.com/reference/android/graphics/drawable/Drawable.html" style="font-family:'courier new',courier,monospace; font-size:14px; font-weight:bold; line-height:21px; color:rgb(37,138,175); text-decoration:initial">Drawable 认彻迸Drawable袿?/div>
class BitmapWorkerTask extends AsyncTask {    ...    @Override    protected void onPostExecute(Bitmap bitmap) {        // if task cancelled , this method is never invoked        // why check here ?         if (isCancelled()) {            bitmap = null;        }        if (imageViewReference != null && bitmap != null) {            final ImageView imageView = imageViewReference.get();            final BitmapWorkerTask bitmapWorkerTask =                    getBitmapWorkerTask(imageView);            // tasktask            if (this == bitmapWorkerTask && imageView != null) {                imageView.setImageBitmap(bitmap);            }        }    }}

mageView??/span> ListView and GridView 迱I以AdaptergetView() ?/span>loadBitmap






>Android

ȵƼ