广告
返回顶部
首页 > 资讯 > 移动开发 >android实现注册页面开发
  • 798
分享到

android实现注册页面开发

2024-04-02 19:04:59 798人浏览 独家记忆
摘要

本文实例为大家分享了Android实现注册页面开发的具体代码,供大家参考,具体内容如下 在values文件里创建以下几个文件 colors代码: <?xml version

本文实例为大家分享了Android实现注册页面开发的具体代码,供大家参考,具体内容如下

在values文件里创建以下几个文件

colors代码:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="purple_200">#FFBB86FC</color>
    <color name="purple_500">#FF6200EE</color>
    <color name="purple_700">#FF3700B3</color>
    <color name="teal_200">#FF03DAC5</color>
    <color name="teal_700">#FF018786</color>
    <color name="black">#FF000000</color>
    <color name="white">#FFFFFFFF</color>
</resources>

strings代码块

<resources>
    <string name="app_name">19260234anzidawang</string>
</resources>

修改为自己的学号

styles代码

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="hLine">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">1dp</item>
        <item name="android:background">@android:color/white</item>
    </style>
    <style name="vLine">
        <item name="android:layout_width">1dp</item>
        <item name="android:layout_height">match_parent</item>
        <item name="android:background">@android:color/white</item>
    </style>
    <style name="tvone">
        <item name="android:layout_height">match_parent</item>
        <item name="android:layout_width">0dp</item>
        <item name="android:layout_weight">1</item>
        <item name="android:drawablePadding">8dp</item>
        <item name="android:gravity">center_horizontal</item>
        <item name="android:paddingTop">40dp</item>
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">15dp</item>
    </style>
    <style name="tvtwo">
        <item name="android:layout_width">wrap_content</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginLeft">20dp</item>
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">15dp</item>
    </style>
    <style name="etOne">
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:layout_marginLeft">30dp</item>
        <item name="android:background">@null</item>
        <item name="android:textColor">@android:color/white</item>

    </style>
</resources>

布局文件(activity_main)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
   xmlns:android="Http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/reGISter_bg">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <TextView
            android:id="@+id/tv_title"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:background="#01ceff"
            android:gravity="center"
            android:text="注册"
            android:textColor="@color/white"
            android:textSize="20sp"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="130dp"
            android:orientation="horizontal">
            <TextView
                style="@style/tvone"
                android:drawableTop="@drawable/qq_icon"
                android:text="qq register"/>
            <View style="@style/vLine"/>
            <TextView
                style="@style/tvone"
                android:drawableTop="@drawable/weixin_icon"
                android:text="wechat register"/>


        </LinearLayout>
        <View style="@style/hLine"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal"
            android:padding="15dp">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/email_icon"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_marginLeft="15dp"
                android:text="use email register"
                android:textColor="@android:color/white"
                android:textSize="15sp"/>
        </LinearLayout>
        <View style="@style/hLine" />
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="15dp">
            <TextView
                style="@style/tvtwo"
                android:text="name"/>
            <EditText
                android:id="@+id/et_name"
                style="@style/etOne"/>
        </LinearLayout>
        <View style="@style/hLine"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="15dp">
            <TextView
                style="@style/tvtwo"
                android:text="email"/>
            <EditText
                android:id="@+id/et_mail"
                style="@style/etOne"/>
        </LinearLayout>
        <View style="@style/hLine"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="15dp">
            <TextView
                style="@style/tvtwo"
                android:text="passWord"/>
            <EditText
                android:id="@+id/et_pwd"
                style="@style/etOne"
                android:inputType="textPassword"/>
        </LinearLayout>

        <View  style="@style/hLine"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="15dp">
            <TextView
                style="@style/tvtwo"
                android:text="glender"/>
                <RadioGroup
                    android:id="@+id/rg_sex"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="50dp"
                    android:orientation="horizontal">
                    <RadioButton
                        android:id="@+id/rb_boy"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="man"
                        android:textColor="@android:color/white"
                        android:textSize="15sp"/>
                <RadioButton
                    android:id="@+id/rb_girl"
                    style="@style/tvtwo"
                    android:text="woman"/>
                </RadioGroup>
        </LinearLayout>
        <View style="@style/hLine"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:padding="15dp">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="chose your hobby"
                android:textColor="@android:color/white"
                android:textSize="15sp"/>
            <CheckBox
                android:id="@+id/cb_sing"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="sing"
                android:textColor="@android:color/white"
                android:textSize="15sp"/>
            <CheckBox
                android:id="@+id/cb_dance"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="dancing"
                android:textColor="@android:color/white"
                android:textSize="15sp"/>
            <CheckBox
                android:id="@+id/cb_read"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="read"
                android:textColor="@android:color/white"
                android:textSize="15sp"/>
        </LinearLayout>
        <View style="@style/hLine"/>
    <View
        android:id="@+id/v_line"
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_above="@+id/btn_submit"
        android:background="@android:color/darker_gray"/>
    <Button
        android:id="@+id/btn_submit"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:gravity="center"
        android:text="uodate"
        android:textColor="@android:color/white"
        android:background="@null"
        android:textSize="18sp"/>
    </LinearLayout>
</RelativeLayout>

在drawable下面创建存放图片的文件

如何创建,首先复制图片.右击drawable,ctrl +v.

选择第一个路径就行.两个路径区别不加以赘述

下面命名就ok.

java代码

package com.example.a19260234zjh;

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 et_name,et_email,et_pwd;
    private Button btn_submit;
    private String name,email,pwd,sex,hobbys;
    private RadioGroup rg_sex;
    private CheckBox cb_sing,cb_dance,cb_read;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }
    private void init(){
        et_name=findViewById(R.id.et_name);
        et_email=findViewById(R.id.et_mail);
        et_pwd=findViewById(R.id.et_pwd);
        rg_sex=findViewById(R.id.rg_sex);
        cb_sing=findViewById(R.id.cb_sing);
        cb_read=findViewById(R.id.cb_read);
        cb_dance=findViewById(R.id.cb_dance);
        btn_submit=findViewById(R.id.btn_submit);
        btn_submit.setOnClickListener(this);
        cb_sing.setOnCheckedChangeListener(this);
        cb_dance.setOnCheckedChangeListener(this);
        cb_read.setOnCheckedChangeListener(this);
        hobbys=new String();
        rg_sex.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int checkedId) {
                switch (checkedId){
                    case R.id.rb_boy:
                        sex="man";
                    case R.id.rb_girl:
                        sex="woman";
                        break;
                }

            }
        });


    }
    private void getData(){
        name=et_name.getText().toString().trim();
        email=et_email.getText().toString().trim();
        pwd=et_pwd.getText().toString().trim();
    }
    @Override
    public void onClick(View v){
        switch (v.getId()){
            case R.id.btn_submit:
                getData();
                if(TextUtils.isEmpty(name)){
                    Toast.makeText(MainActivity.this,"input name",
                            Toast.LENGTH_SHORT).show();
                }
                else if(TextUtils.isEmpty(email)){
                    Toast.makeText(MainActivity.this,"input email",
                            Toast.LENGTH_SHORT).show();
                }
                else if(TextUtils.isEmpty(pwd)){
                    Toast.makeText(MainActivity.this,"input password",
                            Toast.LENGTH_SHORT).show();
                }
                 else if(TextUtils.isEmpty(sex)){
                    Toast.makeText(MainActivity.this,"input glendar",
                            Toast.LENGTH_SHORT).show();
                }
                 else if(TextUtils.isEmpty(hobbys)){
                    Toast.makeText(MainActivity.this,"input hobbys",
                            Toast.LENGTH_SHORT).show();
                } else{
                     Toast.makeText(MainActivity.this,"success",
                             Toast.LENGTH_SHORT).show();
                    Log.i("MainActivity","infORMation"+"name:"+name+",email:"+email+
                            ",sex"+sex+",hobby"+hobbys);
                }
                 break;
        }
    }
    @Override
    public void onCheckedChanged(CompoundButton buttonViwe,boolean isChecked){
        String motion=buttonViwe.getText().toString();
        if(isChecked){
            if(!hobbys.contains(motion)){
                hobbys=hobbys+motion;
            }
        }else {
            if(hobbys.contains(motion)){
                hobbys=hobbys.replace(motion,"");
            }
        }
    }
}

以上就是实现注册页面所需要的代码.

效果如下:

每个人的图片不一样,效果也不一样.建议图片尽量小一些。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程网。

--结束END--

本文标题: android实现注册页面开发

本文链接: https://www.lsjlt.com/news/147060.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • android实现注册页面开发
    本文实例为大家分享了android实现注册页面开发的具体代码,供大家参考,具体内容如下 在values文件里创建以下几个文件 colors代码: <xml version=...
    99+
    2022-11-13
  • Android实现注册页面
    本文用Android studio制作了简单的手机QQ登录界面,其中界面的布局采用了线性布局、表格布局(不固定布局方法),并给控件绑定监听器,当用户点击登陆按钮时,把用户所填写的注册...
    99+
    2022-11-13
  • Android怎么实现注册页面
    本文小编为大家详细介绍“Android怎么实现注册页面”,内容详细,步骤清晰,细节处理妥当,希望这篇“Android怎么实现注册页面”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。实现的效果图:代码:package...
    99+
    2023-06-30
  • Android实现登录注册页面(上)
    简单的Android开发登录注册,这个是没有连数据库的。 首先,新建项目,新建一个登录页面LoginActivity和注册页面RegisterActivity。 下面是登录页面的代码...
    99+
    2022-11-13
  • Android实现登录注册页面(下)
    前面我们已经完成了登录注册页面的布局,下面我们实现验证登录和记住密码的功能。 我们这里还没用到数据库,所以我们的验证的账号密码,是写死的。 首先进入登录页面,可以从这里跳转到注册页面...
    99+
    2022-11-13
  • Android studio 实现app登录注册页面
    目录 activity_main.xml代码如下 MainActivity.java代码如下 用于高校实现Android studio专业课作业提交,如确实有用,欢迎观众姥爷打赏 该页面实现了注册页面的布局效果,包含用户名,密码,忘记密...
    99+
    2023-10-06
    android-studio adb android android studio
  • Android Studio怎么实现注册页面跳转登录页面
    今天小编给大家分享一下Android Studio怎么实现注册页面跳转登录页面的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了...
    99+
    2023-06-30
  • Android实现注册界面
    本文实例为大家分享了Android实现注册界面的具体代码,供大家参考,具体内容如下 LinearLayout 控制布局TextView 用于显示文字EditText 输入框Radio...
    99+
    2022-11-13
  • Android实现带头像的用户注册页面
    1.首先是注册页面的布局: <?xml version="1.0" encoding="utf-8"?> <LinearLayout x...
    99+
    2022-06-06
    Android
  • Android实现注册页面(携带数据包跳转)
    安卓学习:实现注册页面输入数据,点击注册按钮跳转到另一个页面并显示输入信息 效果: 实现 1.创建安卓文件 2.创建注册界面,勾选为启动页 3.编写代码 启动界面activi...
    99+
    2022-11-13
  • Android开发:登录/注册界面的编写
    在实际开发中,几乎所有的APP都会涉及到用户注册/登录页面的制作,因此本文以Android Studio为开发环境,教大家编写一个登录界面。 新...
    99+
    2022-06-06
    界面 android开发 Android
  • Android开发----实现登录注册页面(创建本地数据库,对注册的账户密码进行存储)
    实现登录注册页面(创建本地数据库,对注册的账户密码进行存储) 写在前面: 本文实现了登录注册页面的开发,创建了本地数据库,存储注册的账户密码。注册账户为手机号,对账户为手机号进行了正则化验证。登录成功...
    99+
    2023-10-21
    数据库 android
  • node.js实现登录注册页面
    本文实例为大家分享了node.js登录注册页面展示的具体代码,供大家参考,具体内容如下 首先需要新建四个文件 一个服务器js 一个保存数据的txt 一个登陆、一个注册页面html 1、注册页面 <...
    99+
    2022-06-04
    页面 node js
  • javaweb实现注册登录页面
    本文实例为大家分享了javaweb实现注册登录页面的具体代码,供大家参考,具体内容如下 <%@ page language="java" contentType="text/h...
    99+
    2022-11-13
  • JS、CSS和HTML实现注册页面
    一个用HTML和CSS实现的注册页面模板,废话不多说了,上代码! 更新:使用JavaScript实现用户名和密码表单校验功能。 代码如下: <!DOCTYPE html&g...
    99+
    2022-11-12
  • Java实现登录与注册页面
    用java实现的登录与注册页面,实现了客户端(浏览器)到服务器(Tomcat)再到后端(servlet程序)数据的交互。这里在注册页面加入了验证码验证。 注册的html代码,页面非常...
    99+
    2022-11-13
  • Android开发 登录注册设计
    用Android Studio 简单的实现登录注册 目录 一、登录界面 activity_login.xml 布局代码: login.java 代码:  二、注册界面  activity_register.xml布局代码: register...
    99+
    2023-09-18
    android android studio
  • js实现注册页面校验功能
    本文实例为大家分享了js实现注册页面的校验代码,供大家参考,具体内容如下 基本操作 document.getElementById():获取页面元素alert():向页面弹出提示框。...
    99+
    2022-11-13
  • JavaScript实现简易登录注册页面
    本文实例为大家分享了JavaScript实现简易登录注册页面的具体代码,供大家参考,具体内容如下 <!DOCTYPE html> <html>   <h...
    99+
    2022-11-12
  • JavaScript怎么实现注册登录页面
    本篇内容介绍了“JavaScript怎么实现注册登录页面”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! ...
    99+
    2022-10-19
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作