This is the code for the XML file
<? The XML version="1.0" encoding="utf-8"?>
The android: id="@ + id/activity_main"
Android: layout_width="match_parent"
Android: layout_height="match_parent"
Android: orientation="vertical"
Tools: context="MainActivity" & gt;
Android: layout_height="wrap_content"
Android: layout_margin="20 dp"
The android: orientation="horizontal" & gt;
Android: layout_height="wrap_content"
Android: text="jump welcome"
Android: layout_weight="1"
Android: padding="10 dp"
The android: id="@ + id/b1/& gt;
Java code
Package com. Example. Myapplication;
import androidx.appcompat.app.AppCompatActivity;
The import android. Content. Intent;
The import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
Public class MainActivity extends AppCompatActivity {
The Button for the=(Button) the findViewById (R.i db 1);
@ Override
Protected void onCreate (final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
For the setOnClickListener (new View. An OnClickListener () {
@ Override
Public void onClick (View v) {
Intent Intent=new Intent (MainActivity. This text. The class).
startActivity(intent);
}
});
}
}
CodePudding user response:
The Button for the=(Button) the findViewById (R.i db 1); Written on the setContentView loading activity_main first below is for you