Android Business-use intent Jump interface

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.