In the Multimedia Age, how can I avoid image display? Fortunately, Android provides the Image Display Control imageview.ProgramYou can use this control to change the image displayed on the touch screen.
Program starts running
Click the screen and change the image
Package Snoopy. android; import android. app. activity; import android. OS. bundle; import android. view. view; import android. view. view. onclicklistener; import android. widget. imageview; import android. widget. linearlayout; public class mixview extends activity {// defines an array of access images. These images are saved in the drawable-mdpi folder. I used five Yanzi photos here, pose fans are everywhere ~~~~~~~ Int [] images = new int [] {R. drawable. sunyz_1, R. drawable. sunyz_2, R. drawable. sunyz_3, R. drawable. sunyz_4, R. drawable. sunyz_5,}; int currentimg = 0; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); // obtain the linearlayout layout container linearlayout main = (linearlayout) findviewbyid (R. id. root); // create the imageview component final imageview image = new imageview (this); // Add the imageview component to the linearlayout layout container main. addview (image); // the first image is displayed at initialization. setimageresource (images [0]); image. setonclicklistener (New onclicklistener () {@ overridepublic void onclick (view v) {If (currentimg> = 4) {currentimg =-1;} // change the image displayed in the imageview. setimageresource (images [++ currentimg]) ;}}