广告
返回顶部
首页 > 资讯 > 移动开发 >AndroidStudio实现注册页面跳转登录页面的创建
  • 728
分享到

AndroidStudio实现注册页面跳转登录页面的创建

2024-04-02 19:04:59 728人浏览 八月长安
摘要

本文是用来介绍Android Studio创建注册页面跳转登录页面的界面设计以及跳转功能地实现,完整结构见文章结尾。 用户注册界面 <?xml version="1.0" e

本文是用来介绍Android Studio创建注册页面跳转登录页面的界面设计以及跳转功能地实现,完整结构见文章结尾。

用户注册界面

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/CL"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">
<!---->

<!---->
    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="30dp"
        android:text="用户名:"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="0.047"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.064" />

    <EditText
        android:id="@+id/et1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="72dp"
        android:ems="10"
        android:hint="请输入你的用户名"
        android:inputType="textPersonName"
        app:layout_constraintStart_toEndOf="@+id/textView"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="56dp"
        android:layout_marginLeft="56dp"
        android:layout_marginTop="28dp"
        android:text="密码:"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/et1" />

    <EditText
        android:id="@+id/et2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="30dp"
        android:ems="10"
        android:hint="请输入你的密码"
        android:inputType="textPassWord"
        app:layout_constraintStart_toEndOf="@+id/textView2"
        app:layout_constraintTop_toBottomOf="@+id/et1" />

    <TextView
        android:id="@+id/textView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="28dp"
        android:layout_marginLeft="28dp"
        android:layout_marginTop="24dp"
        android:text="性别"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/et2" />

    <RadioGroup
        android:id="@+id/rg"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="30dp"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="60dp"
        android:orientation="horizontal"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/et2">

        <RadioButton
            android:id="@+id/rb1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="男" />

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

    <TextView
        android:id="@+id/textView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="30dp"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="30dp"
        android:text="兴趣爱好"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/rg" />

    <CheckBox
        android:id="@+id/cb1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="28dp"
        android:layout_marginLeft="28dp"
        android:layout_marginTop="16dp"
        android:text="游戏编程"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/textView4" />

    <CheckBox
        android:id="@+id/cb2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="28dp"
        android:layout_marginLeft="28dp"
        android:text="王者荣耀"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/cb1" />

    <CheckBox
        android:id="@+id/cb3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="28dp"
        android:layout_marginLeft="28dp"
        android:text="看《觉醒年代》"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/cb2" />

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="36dp"
        android:text="注册"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.498"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/cb3" />

    <TextView
        android:id="@+id/tv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="40dp"
        android:text="执行结果"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/button" />


</androidx.constraintlayout.widget.ConstraintLayout>

用户登录界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:xmlna="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#F1EAF3">

        <com.example.myapplication1.TitleLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="90dp"
        android:text="登 录 界 面"
        android:textColor="#232121"
        android:textSize="40dp"
        android:gravity="center">
    </TextView>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#F1EAF3"
        android:paddingLeft="5dip"
        android:paddingRight="5dip"
        android:paddingTop="5dip">

        <LinearLayout
            android:id="@+id/LinearLayout1"
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <TextView
                android:id="@+id/TextView2"
                android:layout_width="wrap_content"
                android:layout_height="40dip"
                android:layout_marginLeft="5dip"
                android:textSize="23Dip"
                android:gravity="center_vertical"
                android:background="#F0E1F3"
                android:text="用户名:">
            </TextView>

            <EditText
                android:id="@+id/EditTextuid"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:layout_marginLeft="0dip"
                android:text=""
                android:textSize="23dip">
            </EditText>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/LinearLayout2"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <TextView
                android:id="@+id/TextView3"
                android:layout_width="wrap_content"
                android:layout_height="40dip"
                android:layout_marginLeft="5dip"
                android:textSize="23dip"
                android:gravity="center_vertical"
                android:background="#F0E1F3"
                android:text="密     码:">
            </TextView>

            <EditText
                android:id="@+id/EditTextPwd"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:singleLine="true"
                android:text="LING"
                android:textSize="23dip">
            </EditText>

        </LinearLayout>

        <LinearLayout
            android:id="@+id/LinearLayout3"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <Button
                android:id="@+id/loginLog"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="23dip"
                android:background="#E8CCEA"
                android:layout_weight="1"
                android:text="登   录">
            </Button>

            <Button
                android:id="@+id/loginClear"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="23dip"
                android:background="#D1B8D3"
                android:layout_weight="1"
                android:text="清   空">
            </Button>

        </LinearLayout>

    </LinearLayout>

    <TextView
        android:id="@+id/all"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="欢迎"
        android:textSize="20sp"/>
</LinearLayout>

java代码实现跳转

package com.example.myapplication1;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

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

public class MainActivity extends AppCompatActivity implements View.OnClickListener,RadioGroup.OnCheckedChangeListener, CompoundButton.OnCheckedChangeListener{
    private Button zc;//声明注册按钮的变量
    RadioGroup rg;//声明单选组的变量
    RadioButton rb1,rb2;//声明单选1,单选2的变量
    CheckBox cb1,cb2,cb3;//声明复选框1,2,3的变量
    EditText et1,et2;声明输入文本框1,2的变量
    TextView tv,txtage,txtall;//声明结果文本的变量


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

        //屏蔽系统自带
        ActionBar actionBar = getSupportActionBar();
        if(actionBar != null){
            actionBar.hide();}

        zc=findViewById(R.id.button);//寻找注册按钮id
        zc.setOnClickListener(this);//给注册按钮安装监听器

        rg=findViewById(R.id.rg);//寻找单选组控件id
        rg.setOnCheckedChangeListener(this);//给单选组安装监听器
        rb1=findViewById(R.id.rb1);//寻找单选控件1id
        rb1.setOnCheckedChangeListener(this);//给单选控件1安装监听器
        rb2=findViewById(R.id.rb2);//寻找单选控件2id
        rb2.setOnCheckedChangeListener(this);//给单选控件2安装监听器

        //txtage=(TextView)findViewById(R.id.age);

        cb1=findViewById(R.id.cb1);//寻找复选框1控件id
        cb1.setOnCheckedChangeListener(this);//给复选框控件1安装监听器
        cb2=findViewById(R.id.cb2);//寻找复选框2控件id
        cb2.setOnCheckedChangeListener(this);//给复选框控件2安装监听器
        cb3=findViewById(R.id.cb3);//寻找复选框3控件id
        cb3.setOnCheckedChangeListener(this);//给复选框控件3安装监听器

        et1=findViewById(R.id.et1);//寻找输入框1控件id
        et2=findViewById(R.id.et2);//寻找输入框2控件id
        tv=findViewById(R.id.tv);//寻找输入框2控件id

    }


    //实现选项按钮组交互功能
    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        switch (checkedId){
            case R.id.rb1:
                System.out.println(rb1.getText().toString());
                break;

            case R.id.rb2:
                System.out.println(rb2.getText().toString());
                break;

        }
    }

    //实现复选框交互功能
    @Override                      //CompoundButton选中或未选中按钮
    public void onCheckedChanged(CompoundButton CompoundButton, boolean b) {
        switch (CompoundButton.getId()) //得到选中或未选中按钮id
        {
            case R.id.cb1: //复选框1id
                if (b==true)//判断复选框1是否为真
                    System.out.println(cb1.getText().toString());
                //如果是真执行复选框按钮输出的结果是得到该文本(cb1对应的text属性文本字符串)字符串
                break;
            case R.id.cb2:
                if (b==true)
                    System.out.println(cb2.getText().toString());
                break;

            case R.id.cb3:
                if (b==true)
                    System.out.println(cb3.getText().toString());
                break;
        }
    }

    //注册按钮实现交互功能
    @Override
    public void  onClick(View view){
        String strname=et1.getText().toString();//获取用户名(ID绑定用户名)
        String strPassword=et2.getText().toString();//获取密码(ID绑定密码)
        //
                int age;
                CharSequence str="";
                if(rb1.isChecked())
                    str=rb1.getText();
                if(rb2.isChecked())
                    str=rb2.getText();

                String str1="";
                if (cb1.isChecked()) str1=str1+"\n"+cb1.getText();
                if (cb2.isChecked()) str1=str1+"\n"+cb2.getText();
                if (cb3.isChecked()) str1=str1+"\n"+cb3.getText();

        //
        if (strname.equals(" ")||strPassword.equals(""))//判断用户名是否等于""并且满足密码等于""
            tv.setText("注册失败,请重新修改信息后再来注册");//否则执行结果文本框输出内容为"注册失败,请重新修改信息后再来注册"
        else
        {
            tv.setText(strname+"注册成功");//如果满足条件的话执行结果文本框输出内容为"注册成功"
             Intent intent=new Intent(MainActivity.this, success.class);
             intent.putExtra("strname",strname);
             intent.putExtra("strPassword",strPassword);
            //intent.putExtra("strname",strname);
            intent.putExtra("sex",str);
            intent.putExtra("str1",str1);
            startActivity(intent);
        }
    }
}

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

--结束END--

本文标题: AndroidStudio实现注册页面跳转登录页面的创建

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

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

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

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

下载Word文档
猜你喜欢
  • AndroidStudio实现注册页面跳转登录页面的创建
    本文是用来介绍Android Studio创建注册页面跳转登录页面的界面设计以及跳转功能地实现,完整结构见文章结尾。 用户注册界面 <xml version="1.0" en...
    99+
    2022-11-13
  • Android Studio怎么实现注册页面跳转登录页面
    今天小编给大家分享一下Android Studio怎么实现注册页面跳转登录页面的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了...
    99+
    2023-06-30
  • jquery实现登陆跳转页面跳转页面跳转
    在Web开发中,很常见的一种需求是用户通过输入账号和密码完成登陆操作后,跳转到不同的页面。这一过程中需要用到Javascript库中非常流行的jQuery来实现。jQuery是一个快速、简洁的JavaScript库,其设计思想是“写更少,做...
    99+
    2023-05-25
  • 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
  • Java实现登录与注册页面
    用java实现的登录与注册页面,实现了客户端(浏览器)到服务器(Tomcat)再到后端(servlet程序)数据的交互。这里在注册页面加入了验证码验证。 注册的html代码,页面非常...
    99+
    2022-11-13
  • Android实现登录注册页面(上)
    简单的Android开发登录注册,这个是没有连数据库的。 首先,新建项目,新建一个登录页面LoginActivity和注册页面RegisterActivity。 下面是登录页面的代码...
    99+
    2022-11-13
  • Android实现登录注册页面(下)
    前面我们已经完成了登录注册页面的布局,下面我们实现验证登录和记住密码的功能。 我们这里还没用到数据库,所以我们的验证的账号密码,是写死的。 首先进入登录页面,可以从这里跳转到注册页面...
    99+
    2022-11-13
  • react.js实现页面登录跳转示例
    1,页面目录信息: 2,从index.js导入路由信息BasicRoute.js,然后BasicRoute.js中存储App.js和StatisticsInformation.js...
    99+
    2023-01-31
    react.js登录跳转 react.js页面跳转
  • JavaScript实现简易登录注册页面
    本文实例为大家分享了JavaScript实现简易登录注册页面的具体代码,供大家参考,具体内容如下 <!DOCTYPE html> <html>   <h...
    99+
    2022-11-12
  • Android studio 实现app登录注册页面
    目录 activity_main.xml代码如下 MainActivity.java代码如下 用于高校实现Android studio专业课作业提交,如确实有用,欢迎观众姥爷打赏 该页面实现了注册页面的布局效果,包含用户名,密码,忘记密...
    99+
    2023-10-06
    android-studio adb android android studio
  • JavaScript怎么实现注册登录页面
    本篇内容介绍了“JavaScript怎么实现注册登录页面”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成! ...
    99+
    2022-10-19
  • jsp注册按钮跳转页面怎么实现
    要实现jsp注册按钮跳转页面,可以使用以下方法:1. 使用HTML表单:在jsp页面中创建一个HTML表单,其中包含一个注册按钮,并...
    99+
    2023-08-09
    jsp
  • php如何实现从登录页直接跳转到注册页
    这篇文章主要讲解了“php如何实现从登录页直接跳转到注册页”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“php如何实现从登录页直接跳转到注册页”吧!首先,我们要先编写一个基本的登录页面。以下...
    99+
    2023-07-05
  • Java怎么实现登录与注册页面
    本文小编为大家详细介绍“Java怎么实现登录与注册页面”,内容详细,步骤清晰,细节处理妥当,希望这篇“Java怎么实现登录与注册页面”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。用java实现的登录与注册页面,实...
    99+
    2023-06-30
  • Android实现注册页面(携带数据包跳转)
    安卓学习:实现注册页面输入数据,点击注册按钮跳转到另一个页面并显示输入信息 效果: 实现 1.创建安卓文件 2.创建注册界面,勾选为启动页 3.编写代码 启动界面activi...
    99+
    2022-11-13
  • 基于Viewpager2实现登录注册引导页面
    本文实例为大家分享了Viewpager2实现登录注册引导页面的具体代码,供大家参考,具体内容如下 介绍 屏幕滑动是两个完整屏幕之间的切换,在设置向导或幻灯片等界面中很常见 实现图(图...
    99+
    2022-11-13
  • JavaScript如何实现简易登录注册页面
    小编给大家分享一下JavaScript如何实现简易登录注册页面,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!具体内容如下<!DOCTYPE htm...
    99+
    2023-06-26
  • require.js与bootstrap结合怎么实现页面登录和页面跳转功能
    这篇文章主要介绍了require.js与bootstrap结合怎么实现页面登录和页面跳转功能,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。页...
    99+
    2022-10-19
  • JavaFx实现登录成功跳转到程序主页面
    本文实例为大家分享了JavaFx实现登录成功跳转到程序主页面的具体代码,供大家参考,具体内容如下 1、需求 登录页面在输入账号密码之后,验证账号密码时候正确,正确就跳转到应用程序的首...
    99+
    2022-11-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作