安卓07作业及总结 -注册界面及跳转

作业:注册界面及跳转
首先创建两个Activity模板,这里我创建的是
RegisterAc以及 ZCCG ,一个应用于注册界面,另一个应用于注册成功后所跳转的界面。
在这里插入图片描述
先把注册的基础界面弄出来,所以先编写创建Activity时生成的layout里所对应的文件。
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_name"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_sex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_sex"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_sex"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_age"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_age"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_age"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_phone"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_email"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_index"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_index"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_index"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    android:paddingTop="30dp"
    android:orientation="horizontal">

    <TextView
        android:id="@+id/Re_remark"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/Re_remark"
        android:textColor="#000000"
        android:textSize="20sp"/>

    <EditText
        android:id="@+id/edt_remark"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="15"
        android:singleLine="true"/>
</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="30dp"
    android:gravity="center_horizontal"
    android:orientation="horizontal">

    <Button
        android:id="@+id/btn_register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="30dp"
        android:paddingRight="30dp"
        android:text="@string/register"

        android:textSize="20sp"/>

    <Button
        android:id="@+id/btn_cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="30dp"
        android:paddingRight="30dp"
        android:text="@string/cancel"

        android:textSize="20sp"/>

</LinearLayout>
然后在Values 的strings里面添加会用到的数据 ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210112163229574.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQ2MjA0MzAy,size_16,color_FFFFFF,t_70) ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210112163235620.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQ2MjA0MzAy,size_16,color_FFFFFF,t_70) ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210112163248635.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L20wXzQ2MjA0MzAy,size_16,color_FFFFFF,t_70) package net.zxj.demo0303;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

public class RegisterAc extends AppCompatActivity {
private EditText edtRename;
private EditText edtResex;
private EditText edtReage;
private EditText edtRephone;
private EditText edtReemail;
private EditText edtReindex;
private EditText edtReremark;
private Button btnRegister;
private Button btnCancel;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    //在活动栏显示图标
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setLogo(R.mipmap.ic_launcher);

    edtRename =findViewById(R.id.edt_name);
    edtResex = findViewById(R.id.edt_sex);
    edtReage = findViewById(R.id.edt_age);
    edtRephone = findViewById(R.id.edt_phone);
    edtReemail = findViewById(R.id.edt_email);
    edtReindex = findViewById(R.id.edt_index);
    edtReremark = findViewById(R.id.edt_remark);
    btnRegister = findViewById(R.id.btn_register);
    btnCancel = findViewById(R.id.btn_cancel);

    btnRegister.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            String strRename = edtRename.getText().toString().trim();
            String strResex = edtResex.getText().toString().trim();
            String strReage = edtReage.getText().toString().trim();
            String strRephone = edtRephone.getText().toString().trim();
            String strReemail = edtReemail.getText().toString().trim();
            String strReremark = edtReremark.getText().toString().trim();
            String strReindex = edtReindex.getText().toString().trim();

            Intent intentRe = new Intent(RegisterAc.this,ZCCG.class);
            //创建数据包,封装数据
            Bundle re =new Bundle();
            re.putString("Rename",strRename);
            re.putString("Reage",strReage);
            re.putString("Rephone",strRephone);
            re.putString("Reemail",strReemail);
            re.putString("Reremark",strReremark);
            re.putString("Resex",strResex);
            re.putString("Reindex",strReindex);
            //通过意图启动目标组件
            intentRe.putExtras(re);
            startActivity(intentRe);
        }
    });

    btnCancel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

}
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值