Android---page jump

Source: Internet
Author: User

1, first in a layout file (. XML), a jump button (ID btn1) was painted:

<button
Android:id= "@+id/btn1"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"
android:text= "Jump"/>

2. Then declare a private button name in the associated class, such as:

Private Button btn1;

3. Then do the following within the OnCreate method in the class:

(1), assign a value to BTN1, that is, set the button ID of the layout file to associate, such as:

BTN1 = (Button) Findviewbyid (R.ID.BTN1);

(2), to BTN1 binding fixed-point hit event:

Btn1.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {
}
});

TIPS: Added on the class: import Android.view.View;

(3), add click Response Events to Bnt1:

Btn1.setonclicklistener (New View.onclicklistener () {
@Override
public void OnClick (View v) {

Intent is a runtime binding (Run-time binding) mechanism that connects two different components during a program's run.

Page1 is the previously added class, and the active event is added within Androidmanifest.xml (<activity android:name= "Page1" ></activity>), Under the folder where the resource code is stored,
Intent i = new Intent (mainactivity.this, Page1.class);

Start
StartActivity (i);
}
});

Android---page jump

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.