Layout:
Main. xml:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" > <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/logo" /> <TextView android:id="@+id/tv" android:text="Welcom to mojia space" android:layout_below="@drawable/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" /></RelativeLayout>
Other. xml:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:text="Button" /></RelativeLayout>
Main activity:
Package wangxin. activity; import android. app. activity; import android. content. intent; import android. OS. bundle; import android. OS. handler; import android. OS. message; import android. widget. imageview; import android. widget. textview; public class welcomepicactivity extends activity {/** called when the activity is first created. */private textview TV = NULL; private imageview image = NULL; private handler = NULL; private int alpha = 255; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); TV = (textview) findviewbyid (R. id. TV); image = (imageview) findviewbyid (R. id. image); image. setalpha (alpha); thread = new thread (New updateimagethread (); thread. start (); handler = new handler () {@ overridepublic void handlemessage (Message MSG) {// todo auto-generated method stubsystem. out. println (MSG); super. handlemessage (MSG); image. setalpha (alpha); image. invalidate () ;}};} class updateimagethread implements runnable {private int B = 0; @ overridepublic void run () {// todo auto-generated method Stubb = initapp (); try {while (B <2) {If (B = 0) {// imagethread is updated every 50 milliseconds after a delay of 2 seconds. sleep (2000); B = 1;} else {thread. sleep (50);} updateapp (B);} catch (interruptedexception e) {// todo auto-generated catch blocke. printstacktrace () ;}} protected void updateapp (int B) {// todo auto-generated method stubalpha = alpha-5; If (alpha <= 0) {B = 2; intent intent = new intent (this, frm_addbills.class); startactivity (intent); finish ();} handler. sendmessage (handler. obtainmessage ();} public int initapp () {int B = 0; return B ;}}
Otheractivity:
package wangxin.Activity;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class Frm_Addbills extends Activity {private Button btn = null;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.other);btn = (Button) findViewById(R.id.button1);btn.setOnClickListener(new BtnListener());}class BtnListener implements OnClickListener {@Overridepublic void onClick(View arg0) {// TODO Auto-generated method stubFrm_Addbills.this.finish();}}}