2021/2/4

注册java

package com.example.bookkeeping;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class secondActivity extends AppCompatActivity implements View.OnClickListener{
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        initUI3();
    }

    private void initUI3() {
        findViewById(R.id.button11).setOnClickListener(this);
    }

    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.button11://执行按钮4
                Toast.makeText(secondActivity.this, "注册成功", Toast.LENGTH_SHORT).show();
                Intent intent7 =new Intent();
                intent7.setClass(getApplicationContext(), MainActivity.class);
                this.startActivity(intent7);
                break;
        }
    }
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="46dp"
        android:text="用户名:"
        android:textSize="30dp" />

    <EditText
        android:id="@+id/edit_21"
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:hint="请填写用户名"/>


    <TextView
        android:layout_width="wrap_content"
        android:layout_height="46dp"
        android:text="密码:"
        android:textSize="30dp" />

    <EditText
        android:id="@+id/edit_22"
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:hint="请输入密码"/>




    <EditText
        android:id="@+id/edit_23"
        android:layout_width="match_parent"
        android:layout_height="55dp"
        android:hint="再次请输入密码"/>


    <Button
        android:id="@+id/button11"
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:text="注册" />


</LinearLayout>
原文地址:https://www.cnblogs.com/qiangini/p/14865557.html