I have just read a simple Android example of the next frame layout. After a long time, I don't know how to add the image to the drawable in the resource.
For example, how to add a new image resource in the Res/drawable folder of testdemo.
Copy the image to bin \ res \ drawable-hdpi orBin \ res \Click drawable-mdpi and refresh the image in eclipse.
I found a solution for loading image resources online:
Directly copy the image resource to be added, right-click the Res/drawable folder, and select "Paste" to copy the image.
The following is a simple frame layout Android Application example, to achieve a bird flying animation effect, refer to the "big words enterprise Android Application Development practices" 15.2.5 frame layout (framelayout) P110-113 page.CodeAs follows:
Package COM. CCF. birdframe; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. app. activity; import android. graphics. drawable. drawable; import android. view. menu; import android. view. view; import android. widget. framelayout; public class birdactivity extends activity {framelayout frame = NULL; private Boolean flag = true; // This class is called cyclically between two methods, and the interface is updated continuously. Handler {int I = 0; Public void handlemessage (Message MSG) {I ++; // shows show (I % 7) in sequence ); // call the sleep function sleep (50);} public void sleep (long delaymillis) {// determine whether to continue flying if (FLAG) {// actually calls handlemessagesendmessagedelayed (obtainmessage (0), delaymillis );}}} // this method is called to update the foreground image void show (Int J) of the frame layout {// obtain the seven images drawable mybird1 = getresources (). getdrawable (R. drawable. mybird1); drawable mybird2 = getresources (). getdrawable (R. drawable. mybird2); drawable mybird3 = getresources (). getdrawable (R. drawable. mybird3); drawable mybird4 = getresources (). getdrawable (R. drawable. mybird4); drawable mybird5 = getresources (). getdrawable (R. drawable. mybird5); drawable mybird6 = getresources (). getdrawable (R. drawable. mybird6); drawable mybird7 = getresources (). getdrawable (R. drawable. mybird7); // set different foreground switches (j) {Case 0: frame. setforeg Round (mybird1); break; Case 1: frame. setforeground (mybird2); break; Case 2: frame. setforeground (mybird3); break; Case 3: frame. setforeground (mybird4); break; Case 4: frame. setforeground (mybird5); break; Case 5: frame. setforeground (mybird6); break; Case 6: frame. setforeground (mybird7); break ;}@overrideprotected void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontent View (R. layout. activity_bird); frame = (framelayout) findviewbyid (R. id. frame); // create a handler subclass object and call its method final myhandler = new myhandler (); myhandler. sleep (50); // set a click event for the frame. When it is hit, the frame is switched between flying and pausing. setonclicklistener (new view. onclicklistener () {@ overridepublic void onclick (view v) {// todo auto-generated method stubflag =! Flag; myhandler. Sleep (50 );}});}}
The seven images are as follows:
Mybird1 mybird2 mybird3 mybird4
Mybird5 mybird6 mybird7