We know that an app is composed of a number of activity, then the individual acitivity will need to jump and pass the value to ensure the operation of the app, now summarizes the multiple activity between the jump and value transfer.
A simple jump
Androidmanifest.xml
<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Cn.lixyz.activitymanager"> <ApplicationAndroid:allowbackup= "true"Android:icon= "@mipmap/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme"> <ActivityAndroid:name=". Mainactivity "Android:label= "@string/app_name"> <Intent-filter> <ActionAndroid:name= "Android.intent.action.MAIN" /> <categoryAndroid:name= "Android.intent.category.LAUNCHER" /> </Intent-filter> </Activity> <ActivityAndroid:name=". Secondactivity "> </Activity> </Application></Manifest>
View Code
Mainactivity.java
PackageCn.lixyz.activitymanager;Importandroid.content.Intent;Importandroid.support.v7.app.AppCompatActivity;ImportAndroid.os.Bundle;ImportAndroid.util.Log;ImportAndroid.view.Menu;ImportAndroid.view.MenuItem;ImportAndroid.view.View; Public classMainactivityextendsappcompatactivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_main); Findviewbyid (R.id.bt_submit). Setonclicklistener (NewView.onclicklistener () {@Override Public voidOnClick (View v) {Intent Intent=NewIntent (mainactivity. This, Secondactivity.class); StartActivity (Intent); } }); }}
View Code
Activity_main.xml
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:tools= "Http://schemas.android.com/tools"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"Tools:context=". Mainactivity "android:orientation= "vertical"> <EditTextAndroid:id= "@+id/ed_input"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:hint= "Please enter the value you want to pass"/> <ButtonAndroid:id= "@+id/bt_submit"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Submit" /></LinearLayout>
View Code
Secondactivity.java
PackageCn.lixyz.activitymanager;Importandroid.app.Activity;ImportAndroid.os.Bundle;/*** Created by LGB on 2015/8/27.*/ Public classSecondactivityextendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.activity_second); }}
View Code
Activity_second.xml
<?XML version= "1.0" encoding= "Utf-8"?><LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical"> <TextViewAndroid:id= "@+id/tv_text_show"Android:layout_width= "Match_parent"Android:layout_height= "Wrap_content"Android:text= "Default Text"Android:textcolor= "#00ff00"android:textsize= "90SP" /></LinearLayout>
View Code
as can be seen from the code, we use StartActivity () in an activity to pass in a intent object to jump between activity.
Operation Result:
Android notes (20) Jump and value transfer in activity