Android登录界面的注册功能实现(1)

android:textSize=“20sp”

/>

<LinearLayout

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:orientation=“horizontal”

<ImageView

android:id=“@+id/yxlg”

android:layout_marginTop=“12dp”

android:layout_marginLeft=“80dp”

android:layout_width=“30dp”

android:layout_height=“30dp”

android:background=“@drawable/net”

/>

<TextView

android:paddingTop=“5dp”

android:paddingBottom=“5dp”

android:id=“@+id/yxld”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:text=" 用邮箱登录"

android:gravity=“center”

android:textSize=“35sp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”>

<TextView

android:paddingTop=“12dp”

android:layout_width=“wrap_content”

android:layout_height=“60dp”

android:text=“名字:”

android:gravity=“left”

android:textSize=“25sp”

/>

<EditText

android:id=“@+id/mz”

android:paddingTop=“12dp”

android:background=“@null”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:textSize=“30sp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”>

<TextView

android:paddingTop=“12dp”

android:layout_width=“wrap_content”

android:layout_height=“60dp”

android:text=“账号:”

android:gravity=“left”

android:textSize=“25sp”

/>

<EditText

android:id=“@+id/zh”

android:paddingTop=“12dp”

android:background=“@null”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:textSize=“30sp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”>

<TextView

android:paddingTop=“12dp”

android:layout_width=“wrap_content”

android:layout_height=“60dp”

android:text=“密码:”

android:gravity=“left”

android:textSize=“25sp”

/>

<EditText

android:password=“true”

android:id=“@+id/mm”

android:paddingTop=“12dp”

android:background=“@null”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:textSize=“30sp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”>

<TextView

android:paddingTop=“12dp”

android:layout_width=“wrap_content”

android:layout_height=“60dp”

android:text="性别: "

android:gravity=“left”

android:textSize=“25sp”

/>

<RadioGroup

android:id=“@+id/xb”

android:layout_marginTop=“15dp”

android:orientation=“horizontal”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”>

<RadioButton

android:id=“@+id/nan”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“男”

android:textSize=“20sp”

/>

<RadioButton

android:id=“@+id/nu”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“女”

android:textSize=“20sp”

/>

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:orientation=“horizontal”>

<TextView

android:paddingTop=“12dp”

android:layout_width=“wrap_content”

android:layout_height=“60dp”

android:text=“选择你的爱好:”

android:gravity=“left”

android:textSize=“25sp”

/>

<CheckBox

android:id=“@+id/cg”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“唱歌”

android:textSize=“20sp” />

<CheckBox

android:id=“@+id/tw”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“跳舞”

android:textSize=“20sp” />

<CheckBox

android:id=“@+id/ds”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“读书”

android:textSize=“20sp” />

<LinearLayout

android:layout_width=“match_parent”

android:layout_height=“1dp”

android:background=“@color/colorAccent”

<Button

android:id=“@+id/btn1”

android:layout_width=“match_parent”

android:layout_height=“100dp”

android:text=“提交”

android:textSize=“30sp”

/>

注册功能实现

package com.example.registerlogin;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.text.TextUtils;

import android.util.Log;

import android.view.View;

import android.widget.Button;

import android.widget.CheckBox;

import android.widget.CompoundButton;

import android.widget.EditText;

import android.widget.RadioGroup;

import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,CompoundButton.OnCheckedChangeListener{

private EditText mz,zh,mm;

private Button btn1;

private String name,id,pwd,sex,hobby;

private RadioGroup xb;

private CheckBox cg,tw,ds;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

btn1=findViewById(R.id.btn1);

mz=findViewById(R.id.mz);

zh=findViewById(R.id.mz);

mm=findViewById(R.id.mz);

cg=findViewById(R.id.cg);

tw=findViewById(R.id.tw);
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

img

img

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

尾声

对于很多初中级Android工程师而言,想要提升技能,往往是自己摸索成长,不成体系的学习效果低效漫长且无助。 整理的这些架构技术希望对Android开发的朋友们有所参考以及少走弯路,本文的重点是你有没有收获与成长,其余的都不重要,希望读者们能谨记这一点。

最后想要拿高薪实现技术提升薪水得到质的飞跃。最快捷的方式,就是有人可以带着你一起分析,这样学习起来最为高效,所以为了大家能够顺利进阶中高级、架构师,我特地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

  • 思维脑图
  • 性能优化学习笔记


  • 性能优化视频

    当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

地为大家准备了一套高手学习的源码和框架视频等精品Android架构师教程,保证你学了以后保证薪资上升一个台阶。

  • 思维脑图
    [外链图片转存中…(img-yn8yJjVt-1713269741344)]
  • 性能优化学习笔记
    [外链图片转存中…(img-xnaeAgSC-1713269741345)]
    [外链图片转存中…(img-EJ7pOFLM-1713269741346)]

[外链图片转存中…(img-XSpx1qmX-1713269741346)]
[外链图片转存中…(img-4gkINGIr-1713269741347)]

  • 性能优化视频
    [外链图片转存中…(img-b93H7Hgt-1713269741348)]
    当你有了学习线路,学习哪些内容,也知道以后的路怎么走了,理论看多了总要实践的。

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

  • 8
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一个简单的Android注册页面的布局和代码示例: 布局代码:activity_register.xml ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:id="@+id/logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="50dp" android:src="@drawable/logo" /> <EditText android:id="@+id/et_username" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/logo" android:layout_marginTop="50dp" android:hint="用户名" android:padding="10dp" /> <EditText android:id="@+id/et_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/et_username" android:layout_marginTop="10dp" android:hint="密码" android:inputType="textPassword" android:padding="10dp" /> <EditText android:id="@+id/et_confirm_password" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/et_password" android:layout_marginTop="10dp" android:hint="确认密码" android:inputType="textPassword" android:padding="10dp" /> <Button android:id="@+id/btn_register" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/et_confirm_password" android:layout_marginTop="20dp" android:text="注册" android:textColor="@android:color/white" android:background="@color/colorPrimary" android:padding="10dp" /> </RelativeLayout> ``` 代码示例:RegisterActivity.java ```java public class RegisterActivity extends AppCompatActivity { private EditText etUsername, etPassword, etConfirmPassword; private Button btnRegister; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); etUsername = findViewById(R.id.et_username); etPassword = findViewById(R.id.et_password); etConfirmPassword = findViewById(R.id.et_confirm_password); btnRegister = findViewById(R.id.btn_register); btnRegister.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String username = etUsername.getText().toString().trim(); String password = etPassword.getText().toString().trim(); String confirmPassword = etConfirmPassword.getText().toString().trim(); if (username.isEmpty()) { etUsername.setError("请输入用户名"); etUsername.requestFocus(); } else if (password.isEmpty()) { etPassword.setError("请输入密码"); etPassword.requestFocus(); } else if (confirmPassword.isEmpty()) { etConfirmPassword.setError("请确认密码"); etConfirmPassword.requestFocus(); } else if (!password.equals(confirmPassword)) { etConfirmPassword.setError("两次输入的密码不一致"); etConfirmPassword.requestFocus(); } else { // 在此处添加注册逻辑 Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show(); finish(); } } }); } } ``` 这是一个简单的注册页面,包含了用户名、密码和确认密码的输入框,以及一个注册按钮。在单击注册按钮时,它将检查输入字段是否为空,密码是否匹配,并添加注册逻辑。当注册成功时,它将显示一个简短的Toast消息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值