The jump page is basically divided into three steps:
1, initialize a intent; (a intent is enough);
2, incoming intent parameters;
3, call StartActivity (); Implement jump page
The operation is as follows
First you need a project or demo, and then you can start
First put a button in the first layout; (Don't ask me what he does) add an ID to him
Then create a new layout:
Right-click Layout Jump out of the menu there's my name here to him is second
Then create a new Second.java to inherit activity in this rewrite Oncreat () method, and then bind him to the layout
Use Setcontentview (r.layout.); You can do this.
and complete the activity registration in Androidmanifest.xml.
<manifest xmlns:android= "http://schemas.android.com/apk/res/android"
package= " Com.intent.android.intentdemo
<application
android:allowbackup= "true"
Android:ico n= "@mipmap/ic_launcher"
android:label= "@string/app_name"
android:supportsrtl= "true"
Andro Id:theme= "@style/apptheme",
<activity android:name=. Mainactivity "
<intent-filter>
<action android:name=" android.intent.action.m AIN "/>
<category android:name=" Android.intent.category.LAUNCHER "/>
</i Ntent-filter>
</activity>
<!--registration-->
</application>
</manifest& Gt
Add <activity android:name= ". Second" ></activity> to complete the creation of the second page in the place where <!--is registered.
officially started intent. Get the button instance first in Mainactivity.java, and then write a listener event for the button
in there
write Intent Intent = new Intent (Mainactivty.this, Second.class);
StartActivity (Intent);
running the project is finished
Package Com.intent.android.intentdemo;
Import android.content.Intent;
Import android.support.v7.app.AppCompatActivity;
Import Android.os.Bundle;
Import Android.view.View;
Import Android.widget.Button;
public class Mainactivity extends Appcompatactivity {
Private Button bt1;
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.layout.activity_main);
bt1= (Button) Findviewbyid (R.id.button);
Bt1.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {
Intent Intent = new Intent (mainactivity.this,second.class);
StartActivity (Intent);
}
});
}
}
Welcome to continue to pay attention to my blog, stay up late to write a blog really tired. Thank you for your support.
Android Business-use intent Jump interface