Note: The curriculum is designed to complete tasks, not to describe the details ~
Packagecom.example.myapplication;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.os.Handler;ImportAndroid.view.View;ImportAndroid.widget.TextView;/*** Created by cherry blossom fall Dance on 2017/6/13.*/ Public classJumpactivityextendsActivity {TextView TextView; intTime=3; Handler Handler=NewHandler (); @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.jump); TextView=(TextView) Findviewbyid (R.id.textview); Handler.postdelayed (runnable,1000); } Runnable Runnable=NewRunnable () {@Override Public voidrun () { time--; Handler.postdelayed ( This, 1000); Textview.settext ("+" +time+ "s"); if(time==0) {Intent Intent=NewIntent (jumpactivity. This, Testactivity.class); StartActivity (Intent); Finish (); }Else{Textview.setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {Intent Intent=NewIntent (jumpactivity. This, Testactivity.class); StartActivity (Intent); //End Threadhandler.removecallbacks (runnable); Finish (); } }); } } };}
Packagecom.example.myapplication;Importandroid.content.Intent;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle; Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Intent.setclass (mainactivity. This, Jumpactivity.class); StartActivity (Intent); Mainactivity. This. Finish (); } Intent Intent=NewIntent ();}
Packagecom.example.myapplication;Importandroid.app.Activity;ImportAndroid.os.Bundle;Importandroid.support.annotation.Nullable;/*** Created by cherry blossom fall Dance on 2017/6/13.*/ Public classTestactivityextendsActivity {@Overrideprotected voidonCreate (@Nullable Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (r.layout.empty_activity); }}
<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context= "Com.example.myapplication.MainActivity"android:orientation= "vertical"> <ImageViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:src= "@mipmap/bg"/> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "+ 3 seconds"Android:id= "@+id/text"android:textsize= "20DP"Android:layout_alignparentright= "true"/></Relativelayout>
<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:background= "@mipmap /A"/></Relativelayout>
<?XML version= "1.0" encoding= "Utf-8"?><Relativelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"> <ImageViewAndroid:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:src= "@mipmap/bg"/> <TextViewAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:id= "@+id/textview"android:textsize= "20SP"Android:text= "+3s"Android:layout_alignparentright= "true"/></Relativelayout>
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.example.myapplication"> <ApplicationAndroid:allowbackup= "true"Android:icon= "@mipmap/ic_launcher"Android:label= "@string/app_name"Android:roundicon= "@mipmap/ic_launcher_round"Android:supportsrtl= "true"Android:theme= "@style/apptheme"> <ActivityAndroid:name=". Mainactivity "> <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> <ActivityAndroid:name=". Jumpactivity "Android:label= "@string/app_name" > <Meta-dataAndroid:name= "Android.support.PARENT_ACTIVITY"Android:value=". Mainactivity "/> </Activity> <ActivityAndroid:name=". Testactivity "Android:label= "@string/app_name"> <Meta-dataAndroid:name= "Android.support.PARENT_ACTIVITY"Android:value=". Mainactivity "/> </Activity> </Application></Manifest>
Android Course design Sixth day Welcome Interface (JUMP)