今天实现了点击按钮跳转页面。
package com.example.myapp0; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity { Button Btn1,Btn2,Btn3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Btn1=findViewById(R.id.A); Btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(MainActivity.this,PageA.class); startActivity(intent); } }); Btn2=findViewById(R.id.B); Btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(MainActivity.this,PageB.class); startActivity(intent); } }); Btn3=findViewById(R.id.C); Btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(MainActivity.this,PageC.class); startActivity(intent); } }); } }
package com.example.myapp0; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity2 extends AppCompatActivity { Button Btn1,Btn2; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); Btn1=findViewById(R.id.A); Btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(MainActivity2.this,PageA.class); startActivity(intent); } }); Btn2=findViewById(R.id.B); Btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(MainActivity2.this,PageB.class); startActivity(intent); } }); } }