Android注册登录页面2

简介: Android注册登录页面

Android注册登录页面1:https://developer.aliyun.com/article/1473210

Result.java

package top.gaojc.app;

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

import androidx.appcompat.app.AppCompatActivity;

import top.gaojc.app.domain.UserInfo;

public class Result extends AppCompatActivity {

    // 初始化
        // 返回值
    TextView result;

        // 登录按钮
    Button login;

    // 账号
    String zhanghao;

    // 密码
    String mima;

    // 昵称
    String nicheng;

    // 性别
    String xingbie;

    // 爱好
    String aihao;

    // 简介
    String jianjie;


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

        // 绑定
        result = findViewById(R.id.tv_result);

        login = findViewById(R.id.btn_login);

        // 用户信息对象
        UserInfo userInfo = new UserInfo();

        // 获取用户信息
        zhanghao = userInfo.getZhanghao();
        mima = userInfo.getMima();
        nicheng = userInfo.getNicheng();
        xingbie = userInfo.getXingbie();
        aihao = userInfo.getAihao();
        jianjie = userInfo.getJianjie();

        // 设置显示的数据
        result.setText("账号:" + zhanghao + "\n密码:" + mima + "\n昵称:" + nicheng + "\n性别:" + xingbie + "\n爱好:" + aihao + "\n简介:" + jianjie);

        // 监听事件
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(Result.this, Login.class);
                startActivity(intent);
            }
        });
    }
}

Welcome.java

package top.gaojc.app;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import top.gaojc.app.domain.UserInfo;

public class Welcome extends AppCompatActivity {

    // 初始化
    TextView register;

    String nicheng;

    String xingbie;

    // 称谓 先生 or 女士
    String appellation;

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

        // 绑定
        register = findViewById(R.id.tv_register);

        // 获取用户的昵称和性别
        UserInfo userInfo = new UserInfo();
        nicheng = userInfo.getNicheng();
        xingbie = userInfo.getXingbie();

        // 判断男女 昵称后面跟称谓
        if (xingbie.equals("男")){
            appellation = "先生";
        }else {
            appellation = "女士";
        }

        // 输出内容的拼接
        String text = "欢迎" + nicheng + appellation + "!";

        // 打印
        register.setText(text);
    }
}

.xml

activity_login.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".Login"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户登录"
        android:layout_gravity="center"
        android:textSize="25sp"/>

    <TextView
        android:id="@+id/txt"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center"
        android:layout_centerInParent="true" />

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="账号" />

        <EditText
            android:id="@+id/account"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"/>

    </LinearLayout>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="密码" />

        <EditText
            android:id="@+id/password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"/>

    </LinearLayout>

    <Button
        android:id="@+id/login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="登录"/>
</LinearLayout>

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="用户注册"
        android:layout_gravity="center"
        android:textSize="25sp"/>

    <TextView
        android:id="@+id/txt"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:gravity="center"
        android:layout_centerInParent="true" />

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="账号" />

        <EditText
            android:id="@+id/edt_account"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"/>

    </LinearLayout>

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

        <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="密码" />

        <EditText
            android:id="@+id/edt_password"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"/>

    </LinearLayout>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="确认密码" />

        <EditText
            android:id="@+id/edt_confirmPassword"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:inputType="textPassword"/>

    </LinearLayout>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="昵称" />

        <EditText
            android:id="@+id/edt_username"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"/>

    </LinearLayout>

    <RadioGroup
        android:id="@+id/rg_gender"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="性别"/>

        <RadioButton
            android:id="@+id/rb_man"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="男"
            android:checked="true"/>

        <RadioButton
            android:id="@+id/rb_woman"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="女"/>

    </RadioGroup>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="爱好"/>

        <CheckBox
            android:id="@+id/cb_eat"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="吃"/>

        <CheckBox
            android:id="@+id/cb_drink"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="喝" />

        <CheckBox
            android:id="@+id/cb_play"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="玩"/>

        <CheckBox
            android:id="@+id/cb_happy"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="乐"/>

    </LinearLayout>

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

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="简介" />

        <EditText
            android:id="@+id/edt_presentation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:singleLine="true"/>

    </LinearLayout>

    <Button
        android:id="@+id/btn_register"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="注册"
        android:layout_gravity="center"
        android:textSize="20sp"
        android:layout_marginTop="35dp"/>

</LinearLayout>

activity_result.xml

<?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=".Result">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注册成功!"
        android:layout_above="@id/tv_result"
        android:layout_centerHorizontal="true"
        android:textColor="#00ff99"
        android:textSize="30sp"/>

    <!-- 返回内容-->
    <TextView
        android:id="@+id/tv_result"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"/>

    <Button
        android:id="@+id/btn_login"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/tv_result"
        android:layout_centerHorizontal="true"
        android:text="去登录"/>

</RelativeLayout>

activity_result.xml

<?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=".Welcome">

    <TextView
        android:id="@+id/tv_register"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="30sp"/>

</RelativeLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="top.gaojc.app">

    <application
        android:allowBackup="true"
        android:icon="@drawable/wyy"
        android:label="@string/app_name"
        android:roundIcon="@drawable/wyy"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Login"/>
        <activity android:name=".Result" />
        <activity android:name=".Welcome" />
        <activity android:name=".domain.UserInfo"/>
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

页面效果

注册页面

注册成功页面

登录页面

登录成功页面

点击可自行下载

目录
相关文章
|
6天前
|
Android开发
Android实现页面渐变效果
Android实现页面渐变效果
22 1
|
6天前
|
数据安全/隐私保护 Android开发
2023安卓逆向 -- 某合伙apk登录加密分析
2023安卓逆向 -- 某合伙apk登录加密分析
33 0
|
6天前
|
XML Java Android开发
Android App开发网络通信中使用okhttp下载和上传图片、文件讲解及实战(超详细实现用户注册信息上传 附源码)
Android App开发网络通信中使用okhttp下载和上传图片、文件讲解及实战(超详细实现用户注册信息上传 附源码)
188 0
|
5天前
|
Android开发
Android WindowFeature小探究,Android客户端Web页面通用性能优化实践
Android WindowFeature小探究,Android客户端Web页面通用性能优化实践
|
6天前
|
Java Android开发 数据安全/隐私保护
Android注册登录页面1
Android注册登录页面
12 1
|
XML Android开发 数据格式
Android跳转应用安装页面
一.低版本跳转方式 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(uri,"application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivityForResult(intent, 666); uri是apk的uri。
1733 0
|
安全 Android开发
Android O 8.0,版本升级不跳转应用安装页面的完美解决
最近开发遇到了个问题,app升级的时候,其他手机都能正常升级,下载完安装包,跳到安装页面进行新版本的安装。但却有用户反映,华为P10和华为Mate 9升级时,怎么也无法跳转到安装页面。
1543 0
|
4天前
|
设计模式 算法 前端开发
Android面经分享,失业两个月,五一节前拿到Offer,设计思想与代码质量优化+程序性能优化+开发效率优化
Android面经分享,失业两个月,五一节前拿到Offer,设计思想与代码质量优化+程序性能优化+开发效率优化
|
3天前
|
编解码 数据库 Android开发
安卓应用开发:打造高效用户界面的五大技巧
【5月更文挑战第18天】在竞争激烈的应用市场中,一个流畅且直观的用户界面(UI)对于安卓应用的成功至关重要。本文将探讨五种提升安卓应用用户界面性能的技巧,包括合理布局设计、优化资源使用、利用硬件加速、内存管理以及响应式编程。通过这些方法,开发者可以创建出既美观又高效的应用体验,从而吸引和保留用户。
|
4天前
|
XML Android开发 数据格式
ConstraintLayout 2,Android高级开发面试
ConstraintLayout 2,Android高级开发面试