<?xml version="1.0" encoding="utf-8" ?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="xieting" android:onClick="tiaozhuang"/> </RelativeLayout> java package com.commerce.mylifeactivity; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); System.out.println("onCreate() xieting"); } @Override protected void onResume() { super.onResume(); System.out.println("onResume()xieting"); } @Override protected void onStop() { super.onStop(); System.out.println("onResume()xieting"); } @Override protected void onPause() { super.onPause(); System.out.println("onResume()xieting"); } public void tiaozhuang(View view) { Intent intent=new Intent(MainActivity.this,MainActivity2.class); startActivity(intent); finish(); } @Override protected void onDestroy() { super.onDestroy(); System.out.println("onResume()xieting"); } @Override protected void onStart() { super.onStart(); System.out.println("onResume()xieting"); } } xml2 <?xml version="1.0" encoding="utf-8" ?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity2"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="31" android:onClick="tiaozhuangdao"/> </RelativeLayout> java package com.commerce.mylifeactivity; import androidx.appcompat.app.AppCompatActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; public class MainActivity2 extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main2); } public void tiaozhuangdao(View view) { Intent intent=new Intent(MainActivity2.this,MainActivity.class); startActivity(intent); } }