完善登录注册页面
实验内容
综合运用基本组件完成一个注册与登录的应用程序设计。要求基于基础控件,综合使用Intent实现Android的Activity之间信息交换。系统包含启动页、注册页、登录页3个页面,具体要求如下:
在第2周上机作业的基础上,完善登录注册页面。
1.注册页面和功能的实现。
界面除用户名、密码、确认密码之外,增加性别(单选按钮)、学历(spinner)、爱好(复选框)等信息。
使用相对布局。
2.登陆页面和功能的实现。
要求使用Shape和Selector对页面进行美化。按第3章的课件中的提示可完成。
附件内容包括一张用于启动页的图片,2张用于编辑框美化的背景图片。
MainActivity.java
package com.example.myapplication1;import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;public class MainActivity extends AppCompatActivity {private Button button1,button2;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);button1=(Button)findViewById(R.id.button1);//映射activity_main.xml中的id=button1按钮button2=(Button)findViewById(R.id.button2);//映射activity_main.xml中的id=button2按钮final String user = "Admin";final String pass = "I love Android" ;//为两个按钮增加点击事件监听button1.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String username = "";EditText editText1 = (EditText)findViewById(R.id.editText);username = editText1.getText().toString();String password = "";EditText editText2 = (EditText)findViewById(R.id.editText2);password = editText2.getText().toString();if(username.equals(user) && password.equals(pass)){String msg = "欢迎进入DIY!";Toast toast = Toast.makeText(MainActivity.this,msg,Toast.LENGTH_SHORT);toast.setGravity(Gravity.CENTER,0,0);toast.show();Intent intent = new Intent(MainActivity.this,SubActivity1.class);startActivity(intent);}else{String msg = "Wrong username or password.Please try again!";Toast toast = Toast.makeText(MainActivity.this,msg,Toast.LENGTH_SHORT);toast.setGravity(Gravity.CENTER,0,0);toast.show();}}});button2.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {Intent intent=new Intent(MainActivity.this,SubActivity2.class);startActivity(intent);}});}}
SplashActivity.java
package com.example.myapplication1;import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.Window;
import android.view.WindowManager;import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;public class SplashActivity extends AppCompatActivity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.activity_splash);//加上这句设置为全屏不加只隐藏titlegetWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);new Handler().postDelayed(new Runnable() {@Overridepublic void run() {Intent mainIntent = new Intent(SplashActivity.this,MainActivity.class);startActivity(mainIntent);//动画效果overridePendingTransition(R.anim.abc_slide_in_bottom, R.anim.abc_slide_out_bottom);finish();}},3000);}
}
SubActivity1.java
package com.example.myapplication1;import android.app.Activity;
import android.os.Bundle;import androidx.annotation.Nullable;public class SubActivity1 extends Activity {@Overrideprotected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_sub1);/* Button button1;button1=(Button)findViewById(R.id.button1);button1.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String msg = "欢迎进入DIY!";Toast toast = Toast.makeText(SubActivity1.this,msg,Toast.LENGTH_SHORT);toast.setGravity(Gravity.CENTER,0,0);toast.show();}});*/}
}
SubActivity2.java
package com.example.myapplication1;import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import androidx.annotation.Nullable;public class SubActivity2 extends Activity {private Button button3;protected void onCreate(@Nullable Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_sub2);button3=(Button)findViewById(R.id.button3);final EditText usernameET,passwordET;usernameET =(EditText)findViewById(R.id.editText5);passwordET = (EditText)findViewById(R.id.editText6);button3.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {String msg = "您输入的用户名是"+usernameET.getText()+"\n"+"密码是"+passwordET.getText();Toast toast = Toast.makeText(SubActivity2.this,msg,Toast.LENGTH_SHORT);toast.setGravity(Gravity.CENTER,0,0);toast.show();}});}
}
acitivity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns: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"android:orientation="vertical"android:gravity="center_horizontal|center_vertical"tools:context=".MainActivity"android:background="@drawable/background_login"><LinearLayoutandroid:layout_width="225dp"android:layout_height="323dp"android:background="@drawable/background_login_div"android:orientation="vertical"><TextViewandroid:layout_width="223dp"android:layout_height="wrap_content"android:gravity="center"android:text="WELCOME"android:textSize="24sp"android:textStyle="bold"android:layout_marginTop="20dp"/><EditTextandroid:id="@+id/editText"android:layout_width="180dp"android:layout_height="wrap_content"android:background="@drawable/edit_login"android:hint="请输入用户名"android:layout_gravity="center"android:layout_marginTop="20dp"/><EditTextandroid:id="@+id/editText2"android:layout_width="180dp"android:layout_height="wrap_content"android:background="@drawable/edit_login"android:hint="请输入密码"android:inputType="textPassword"android:layout_gravity="center"android:layout_marginTop="20dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:orientation="vertical"android:gravity="center_horizontal|center_vertical"><Buttonandroid:id="@+id/button1"android:layout_width="90dp"android:layout_height="33dp"android:layout_weight="1"android:background="@drawable/background_button_div"android:text="login"android:textSize="16sp"/><Buttonandroid:id="@+id/button2"android:layout_width="90dp"android:layout_height="33dp"android:layout_marginTop="20dp"android:layout_weight="1"android:background="@drawable/background_button_div"android:text="register"android:textSize="16sp"/></LinearLayout></LinearLayout>
</LinearLayout>
activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<!--suppress ALL -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="match_parent"android:layout_height="match_parent"><ImageViewandroid:id="@+id/imageView"android:layout_width="match_parent"android:layout_height="match_parent"android:src="@drawable/jimi1"android:scaleType="fitXY"/></LinearLayout>
activity_sub1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="match_parent"android:layout_height="match_parent"android:weightSum="1"><TextViewandroid:id="@+id/textView3"android:layout_width="match_parent"android:layout_height="match_parent"android:layout_marginTop="200dp"android:layout_weight="1"android:text="欢迎进入DIY!"android:textAlignment="center"android:textSize="24sp"android:textColor="@color/colorAccent"/></LinearLayout>
activity_sub2.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical" android:layout_width="match_parent"android:layout_height="match_parent"><TextViewandroid:id="@+id/signup_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/signup_msg"android:textSize="25sp"android:textStyle="bold"android:layout_centerHorizontal="true"android:layout_marginTop="20dp"/><EditTextandroid:id="@+id/editText5"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/signup_msg"android:layout_marginTop="30dp"android:hint="@string/editText5"android:singleLine="true" /><EditTextandroid:id="@+id/editText6"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="@string/editText6"android:inputType="textPassword"android:layout_below="@id/editText5"/><EditTextandroid:id="@+id/editText7"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/editText6"android:layout_marginTop="2dp"android:hint="@string/editText7"android:inputType="textPassword"tools:ignore="Autofill" /><TextViewandroid:id="@+id/sex_msg"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/sex_msg"android:layout_below="@id/editText7"android:layout_marginTop="8dp"/><RadioGroupandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/editText7"android:layout_toRightOf="@id/sex_msg"android:orientation="horizontal"><RadioButtonandroid:id="@+id/sex_male"android:layout_width="wrap_content"android:layout_height="wrap_content"android:checked="true"android:text="@string/sex_male" /><RadioButtonandroid:id="@+id/sex_female"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/sex_female" /></RadioGroup><TextViewandroid:id="@+id/academic_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/academic_text"android:layout_below="@id/sex_msg"android:layout_marginTop="10dp"/><Spinnerandroid:id="@+id/academic_msg"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/sex_msg"android:layout_marginStart="7dp"android:layout_marginLeft="7dp"android:layout_marginTop="8dp"android:layout_toEndOf="@+id/academic_text"android:layout_toRightOf="@+id/academic_text"android:entries="@array/academic"android:fadeScrollbars="true"android:prompt="@string/academic_prompt"android:scrollIndicators="right"android:spinnerMode="dialog"></Spinner><LinearLayout android:orientation="horizontal"android:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/hobby_msg"android:layout_below="@id/academic_msg"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="爱好"/><CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/hobby_swim"android:text="游泳"/><CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/hobby_music"android:text="音乐"/><CheckBoxandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:id="@+id/hobby_book"android:text="读书"/></LinearLayout><Buttonandroid:id="@+id/button3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="@string/button3"android:layout_centerHorizontal="true"android:layout_below="@id/hobby_msg"/>
</RelativeLayout>
background_button_div.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><solid android:color="#FF72CAE1"/><cornersandroid:bottomLeftRadius="10dp"android:bottomRightRadius="10dp"android:topLeftRadius="10dp"android:topRightRadius="10dp"/>
</shape>
background_login.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><gradientandroid:angle="45"android:endColor="#FF72CAE1"android:startColor="#FFACDAE5"/></shape>
background_login_div.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><solid android:color="#55FFFFFF"/><cornersandroid:bottomLeftRadius="25dp"android:bottomRightRadius="25dp"android:topLeftRadius="25dp"android:topRightRadius="25dp"/></shape>
edit_login.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"><item android:state_enabled="false"android:drawable="@drawable/login_input"/><item android:state_focused="true"android:drawable="@drawable/input_over"/></selector>
相关文章:

EF 批量 添加 修改 删除
1批量添加 db.T_Investigator.AddRange(list) 2批量删除 db.T_Investigator.RemoveRange(list) 3批量修改 for 循环修改。 注意: 先查询出来,最后savechange(),写在一个事务中,一次请求一个上下文。…

在IE7中无效的解决办法
通过ShowModalDialog 打开页面,在POSTBACK时,打开新的页面, 在IE6下没问题,只有在IE7下,会重新打开一新页面, 其实只要把<base target"_self"/> 放到 <head>下即可。 <head> <base target"_self"/> …
简单的纹理管理器
简单的纹理管理器 罗朝辉 (http://www.cnblogs.com/kesalin/)本文遵循“署名-非商业用途-保持一致”创作公用协议游戏中的资源一般都是由资源管理器来处理的,资源管理器负责载入,释放,以及根据资源ID返回相关资源供游戏程序使用。下面改写sph…

记住密码以及Android 列表的操作
1.综合使用RecycleView,CardView,Adapter实现一个宝宝相册,并将其加入到实验一形成的应用中,使得:用户成功登录后转到宝宝相册所在的主界面。还要求实现:用户单击对应的列表子项的不同部位时给出不同的Toas…

python-----利用filecmp删除重复文件
以下代码素材自取:链接:https://pan.baidu.com/s/1fL17RjKyGjpvpeeUFONCaQ 提取码:zgiw # coding:utf-8 import os import filecmp# 将指定目录下的所有文件的路径存储到all_files变量中 def get_all_files(path, dirs):all_files []for d …

如何设置REUSE_ALV_GRID_DISPLAY'的单个单元格的是否可以输入
代码如下:具体说明参见红色说明(本例子是从订单明细提取两个字段的数据到内表) REPORT ZALV_EDIT.TYPE-POOLS: SLIS.*- FieldcatalogDATA: IT_FIELDCAT TYPE LVC_T_FCAT.DATA: X_FIELDCAT TYPE LVC_S_FCAT.DATA: X_LAYOUT TYPE LVC_S_LAYO. "第1步:…

记一次生产的bug
第一个在代码中使用 new SimpleDateFormat("EEEE")来判断周几。在本地测试过程中通过日志打印出来的周几 比如周日对应的是中文汉字“星期日”,然后使用判断 if("星期日".equals(weekDay)){ } (其中weekDay是要使用的日期)。在本地测试通过后…

企业ERP制度的“执行力”
一直都很想说这个话题。可能很多人不是太理解这个标题,企业ERP制度是指完成了ERP系统实施的企业,为了维持ERP系统的持续运行而建立的ERP运行制度。执行力就不用多说了,就是ERP运行制度到底执行了多少,怎么执行的问题。许多管理软件…

python学习点滴记录-Day10-线程
多线程 协程 io模型 并发编程需要掌握的点: 1 生产者消费者模型2 进程池线程池3 回调函数4 GIL全局解释器锁 线程 理论部分 (摘自egon老师博客) 一、定义: 在传统操作系统中,每个进程有一个地址空间,而且默…

适配设备的简易新闻浏览器
同时兼容手机和平板。 进入应用后先显示新闻列表,当在手机上使用时,使用单页模式,单击列表项会打开新的页面。 当在平板上使用时,使用双页模式,单击左侧列表项时直接更新右侧新闻内容页。 MainActivity.java pack…

this.$router.push、replace、go的区别
1.this.$router.push() 描述:跳转到不同的url,但这个方法会向history栈添加一个记录,点击后退会返回到上一个页面。 用法: 2.this.$router.replace() 描述:同样是跳转到指定的url,但是这个方法不会向histor…

jQuery 实现图片的特效1[原]
用jQuery实现图片的动画效果非常简单.以下演示 jQuery里面所用到的参数 HIDE SHOW FADEOUT FADEIN 的不同. 在线演示:单击演示 代码分析: //hide and show fadeout and fadein $("input:eq(0)").click(function(){ $("img").fadeOut(3000); }); …

【设计模式】 模式PK:策略模式VS状态模式
1、概述 行为类设计模式中,状态模式和策略模式是亲兄弟,两者非常相似,我们先看看两者的通用类图,把两者放在一起比较一下。 策略模式(左)和状态模式(右)的通用类图。 两个类图非常相…

vs2008与IIS 7.0使用在vista上时出现的问题及解决方法(Internet Explorer 无法显示该页面)(VS2008: IE Cannot Display Web Page)...
我的系统是Vista Ultimate SP1,先安装了vs2008 ,然后再安装了IIS7.0之后就出现了一系列的问题。 问题:通过vs2008启动程序调试时报错。错误提示为:Internet Explorer 无法显示该页面 解决方法: 首先是安装一些必要的附件程序。 1.打开控制面板…

云服务中IaaS、PaaS、SaaS的区别
越来越多的软件,开始采用云服务。 云服务只是一个统称,可以分成三大类。 IaaS:基础设施服务,Infrastructure-as-a-servicePaaS:平台服务,Platform-as-a-serviceSaaS:软件服务,Softwa…

Android项目框架综合实例
综合使用ViewPager、Fragment、RecycleView等,实现类似“网易新闻浏览器 ”的项目综合框架,要求实现: 底部导航,分别是“首页”,“视频”,“讲讲”,“我的”;底部导航不要求滑动翻页…

配置Windows Server 2003 的RADIUS Server的方法
配置Windows Server 2003 的RADIUS Server的方法1、安装Windows 2003操作系统;2、添加角色(须插网线);3、添加组件->网络服务、证书服务;4、管理工具->域安全策略->帐户策略->密码策略;&#x…

Y15BeTa蜂鸣器唱歌程序-演奏版
最优版,自由演奏你的音乐! 每天进步一点点! 2018-12-09最新版 #include<bits/stdc.h> #include<windows.h> using namespace std; int md[8]{0,262,294,330,349,392,440,494}, mz[8]{0,523,587,659,698,784,880,988}, mg[8]{0,10…

实验6 触发器的使用
实验6 触发器的使用 实验目的 掌握触发器的创建、修改和删除操作。 掌握触发器的触发执行。 掌握触发器与约束的不同。二、实验要求 1.创建触发器。 2.触发器执行触发器。 3.验证约束与触发器的不同作用期。 4.删除新创建的触发器。 三、实验内容 (一&#x…

神经网络二(Neural Network)
#!/usr/bin/env python # -*- coding: utf-8 -*- """ __title__ __author__ wlc __mtime__ 2017/9/04 """ import numpy as np import randomclass Network(object):def __init__(self,sizes):#size神经元个数list[3,2,4]self.num_layers l…

要想成功 需要了解的东西
凭我工作的经历来看 在it界要想成功必须要做到以下几点。 1 基本的开发语言不一定精通,但是一定要熟练的使用。 2 对公的主营业务一定要熟悉,不但要熟悉,而且要烂熟于心。如果不能做到这一点,那么起码对自己负责的工作要做到烂熟…

合并下载的Solaris镜像为DVD文件的方法
有很多朋友想安装solaris10操作系统,但是没有系统盘或者在官方网站下载之后不会合成。经过多次试验之后现在把正确的方法写下,以方便大家的学习之用。1。先到官方网站下载最新的系统包,下载之后的软件包为:sol-10-u4-ga-x86-dvd-i…

oracle测试环境表空间清理
测试场景下,使用的oralce遇到表空间的占用超大,可以采用如下的方式进行空间的清理 首先使用sqlplus连接数据库sqlplus sys/passwordorcl as sysdba 之类进行数据库的连接没然后进行如下的操作 ##创建表空间对于自己的测试库和表等最好都建立自己的表空间…

Google Chrome(谷歌浏览器) 发布下载
Google Chrome 下载地址:http://www.google.com/chrome 刚刚装上,还没怎么用,说一下大概印象,整体非常简洁,只有两个菜单选项。访问上明显感觉很快,比 Firefox 快,也比 IE7快;对网页…

实验 5 数据的完整性管理
实验 5 数据的完整性管理 一、实验目的 掌握实体完整性的实现方法。掌握用户定义完整性的实现方法。掌握参照完整性的方法。二、实验内容 数据库的完整性设置。三、实验步骤 可视化界面的操作方法:实体完整性 将 student 表的“sno”字段设为主键:在表…

16-acrobat por 简单使用指南
用于pdf编辑,这里我主要讲下图片的切割和保存,以及合并: 切割选中区域双击 合并的话,在编辑界面选中对象,复制,在另一个pdf的编辑界面粘贴,并挪动位置: 转载于:https://www.cnblogs.…

可突破任意ARP防火墙,以限制流量为目标的简单网络管理软件
以下消息来自幻影论坛[Ph4nt0m]邮件组软件说明:可突破任意ARP防火墙,以限制流量为目标的简单网络管理软件。使用方法:1.在参数设置中选择好工作网卡;2.检查网关信息和本机信息是否正确,如果不正确,请手动输…

OpenCV 学习笔记03 boundingRect、minAreaRect、minEnclosingCircle、boxPoints、int0、circle、rectangle函数的用法...
函数中的代码是部分代码,详细代码在最后 1 cv2.boundingRect 作用:矩形边框(boundingRect),用于计算图像一系列点的外部矩形边界。 cv2.boundingRect(array) -> retval 参数: array - 灰度图像ÿ…

实验1 应用SQL Server进行数据定义和管理
实验1 应用SQL Server进行数据定义和管理 【实验目的】 1)熟悉SQL Server的配置和管理。 2)掌握数据库的定义和修改方法。 3)掌握表的定义和修改方法。 4)掌握使用SQL语句进行数据管理的方法。 【实验环境】 SQL Server 20…

谷歌Chrome浏览器发布
谷歌已提前启用了浏览器Google Chrome的官方网站gears.google.com/chrome/,今天该浏览器的Windows版本首发。在此以前,谷歌与微软之间的斗争更象是“冷战”,大多局限于谷歌开发小型的、基于网络的软件,与微软占主导地位的Word、Po…