1. Implemented functions
Click the page button to switch to the next page.
Two, the main code
1) The first page
We need to implement clicking the login button to switch pages
A Button is set in the layout, and only part of the code of the button is displayed
<!-- 登录按钮行 --> <Button android:id="@+id/loginBtn" android:layout_width="220dp" android:layout_height="60dp" android:layout_marginTop="16dp" android:background="@drawable/shape" android:text="登录" android:textColor="#ffffff" android:textSize="16sp" >
Login page LoginActivity code,
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Button button; button = findViewById(R.id.loginBtn); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // 显示跳转 //第二个页面MainActivity Intent intent = new Intent(LoginActivity.this, MainActivity.class); startActivity(intent); } }); }
3. Startup page
The startup page should be set as the first page, in AndroidMainfest.xml
<activity android:name=".LoginActivity" android:exported="true" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <meta-data android:name="android.app.lib_name" android:value="" /> </activity>