If you write a list and click an image to preview the image
Can be written in the form of inheriting AlertDialog:
Click a chart:
Public void onClick (View v) {viewBigsizeBmp (ImageView) v ). getDrawable (), Constants. preview_bmp _dir_suffix);} private void viewBigsizeBmp (Drawable drawable, String suffix) {final String sdDir = Utils. getSDPath (); final String saveDir = TextUtils. isEmpty (sdDir )? MCacheDir: sdDir + suffix; if (mBlog! = Null & mBlog. pic! = Null) {ImageViewerDialog dialog = new ImageViewerDialog (context, mBlog. pic, saveDir, drawable, suffix); // mBlog. pic is the image request address, such as success (true); dialog. show (); dialog. setOnCancelListener (new alertdiener. onCancelListener () {@ Overridepublic void onCancel (DialogInterface dialog) {}}); WindowManager. layoutParams lp = dialog. getWindow (). getAttributes (); lp. width = context. getResources (). getDimensionPixelSize (R. dimen. dialog_width); lp. height = context. getResources (). getDimensionPixelSize (R. dimen. dialog_height); dialog. getWindow (). setAttributes (lp );}}
Then write the Dialog:
Public class ImageViewerDialog extends AlertDialog {private Context context; private LayoutInflater inflater; private LinearLayout layout; private ImageView iv; private ProgressBar pb; private String uri; private AsyncTask
LoadPicTask; // String picfilePath; public boolean loadPictureRunning; private boolean finishPicLoad; private boolean isRedirectBlog; // private File downloadedImage; private LoadPictureTask mldPicTsk; private String mSaveDir; protected void onCreate (Bundle savedInstanceState) {// TODO Auto-generated method stubsuper. onCreate (savedInstanceState); this. setContentView (layout); try {new loadpicturetask(cmd.exe cute ();} catch (RejectedExecutionException e) {}} private class LoadPictureTask extends AsyncTask
{Protected Object [] doInBackground (Object... args) {Bitmap bmp = null; try {bmp = Utils. getPreviewBitmap (uri, context. getCacheDir (). getAbsolutePath (), context, null, false, Constants. preview_bmp _dir_suffix);} catch (Exception e) {// Utils. loge (e); return null;} return new Object [] {bmp};} protected void onPostExecute (Object [] objs) {loadPictureRunning = false; if (objs! = Null & objs [0]! = Null) {pb. setVisibility (View. GONE); iv. setImageBitmap (Bitmap) objs [0]); finishPicLoad = true ;}} protected void onPreExecute () {super. onPreExecute () ;}} public ImageViewerDialog (Context context, String uri, String dir, Drawable drawable, String suffix) {super (context); this. context = context; this. mSaveDir = dir; inflater = LayoutInflater. from (context); layout = (LinearLayout) inflater. inflate (R. layout. imageviewerdialog, null); iv = (ImageView) layout. findViewById (R. id. ivImage); iv. setOnClickListener (new ImageView. onClickListener () {public void onClick (View v) {// TODO Auto-generated method stubdismiss () ;}}); pb = (ProgressBar) layout. findViewById (R. id. progressBar01); pb. setBackgroundDrawable (drawable); this. uri = uri ;}}
Layout of this Dialog:
: