There are two ways to click on thumbnails in Android to view large images, one is to have a list page of Sina Weibo, pop up a window to display a large image (the original activity is the background). The other is to directly open a new activity to display a larger image.
1, the first method we can use the custom Alertdialog to implement, the code is as follows: ImageView image= (ImageView) Findviewbyid (r.id.small_image); Image.setonclicklistener (New Onclicklistener () {//click to enlarge public void OnClick (View paramview) {Layoutinflater Inflater = La Youtinflater.from (context);View Imgentryview = inflater.inflate (r.layout.dialog_photo_entry, null);Loading a custom layout fileFinal Alertdialog Dialog = new Alertdialog.builder (context). Create ();ImageView img = (ImageView) Imgentryview.findviewbyid (r.id.large_image); Imagedownloader.download ("Picture Address", IMG); This is the load network picture, can be your own picture setting methodDialog.setview (Imgentryview);//Custom Dialogdialog.show ();//Click on the layout file (can also be understood as a click on the larger image) after closing dialog, here the dialog does not need a buttonImgentryview.setonclicklistener (New Onclicklistener () {public void OnClick (View paramview) {Dialog.cancel ();}});}}); The corresponding layout file dialog_photo_entry content is: <?xml version= "1.0" encoding= "Utf-8"? ><relativelayout android:layout_width= "Fill_parent" android:layout_height= "wrap_content" xmlns:android= "Http://schemas.android.com/apk/res/android" > <ImageViewandroid:layout_height= "Wrap_content" android:id= "@+id/Large_image"Android:layout_width=" Wrap_content "android:layout_centerhorizontal=" true "android:layout_centervertical=" true " ></ImageView></RelativeLayout> 2, another way to open a new activity is a relatively simple point, the large map activity code is as follows: public void OnCreate ( Bundle savedinstancestate) {super.oncreate (savedinstancestate); Requestwindowfeature (Window.feature_no_title); Setcontentview (r.layout.dialog_photo_entry); activity = this; Bundle bundle = This.getintent (). Getextras (); if (bundle!=null) {picname = bundle.getstring ("Picname");//Picture name}imageview img = (ImageView) This.findviewbyid (r.id.Large_image); Imagedownloader.download (Picname, IMG); Toast toast = Toast.maketext (This, "click image to return", Toast.length_short); toast.setgravity (gravity.bottom, 0, 0); Toast.show ( ); Img.setonclicklistener (new View.onclicklistener () {//Click to return to public void OnClick (View paramview) {activity.finish ();}});} The corresponding layout filedialog_photo_entry content is:<?xml version= "1.0" encoding= "Utf-8"? ><linearlayout xmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "android:orientation=" vertical " ><ScrollViewAndroid:layout_width= "Fill_parent" android:layout_height= "wrap_content" android:id= "@+id/entry_pic" Android: Layout_margin= "0dip" android:padding= "0dip" > <imageview android:layout_height= "wrap_content" android:id= "@+ ID/Large_image"Android:layout_margintop=" 0dip "android:paddingtop=" 0dip "android:adjustviewbounds=" true "android:layou T_width= "Fill_parent" ></ImageView></ScrollView></LinearLayout>