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