**

QQ注册功能实现 案例小结

**

*1、新建(添加)Activity界面(从注册界面—注册成功接收注册内容界面)
方法:java下------第一个文件夹 右击----new-----activity—empty activity
2、按钮的监听事件,实现界面的跳转,并且将注册的数据,提交给成功界面
(1)定义组件对象
(2)实例化对象(将xml中的组件,强类型转化为java中对象)
(3)编写对象的事件方法(按钮的事件方法,两种类型)
I、编写监听事件: 按钮对象名.setOnClickListener()
II、单独定义按钮的onclick的事件doClick。 android:onClick=“doClick()”
3、实现跳转,需要Intent意图、目的对象,并且实现数据传递
(1)定义Intent意图 Intent intent=new Intent(当前界面.this,下一个界面.class);
(2)通过intent写入数据 intent.putExtra(“键”,“值”)//键值对
(3)数据是如何获取的? etName.getText()
(4)执行你的意图 startActivity(intent)
4、接收上一界面(意图)传来的数据
(1)定义Intent意图,获取意图getIntent(),并得到数据getStringExtra()
(2)通过组件TextView,将得到的数据赋值给组件TextView

1、activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="QQ会员注册信息"android:textSize="30sp"android:layout_marginTop="30dp"android:layout_gravity="center"/>
<LinearLayoutandroid:layout_marginTop="20dp"android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:text="账号:"android:textSize="26sp"android:layout_marginLeft="50dp"android:layout_width="wrap_content"android:layout_height="wrap_content"/><EditTextandroid:id="@+id/etname"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginRight="50dp"android:textSize="20sp"android:hint="输入数字号码"/></LinearLayout>
<LinearLayoutandroid:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content" ><TextViewandroid:text="密码:"android:textSize="26sp"android:layout_marginLeft="50dp"android:layout_width="wrap_content"android:layout_height="wrap_content"/><EditTextandroid:id="@+id/etpwd"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginRight="50dp"android:textSize="20sp"android:inputType="numberPassword"android:maxLength="6"android:hint="输入密码信息"/></LinearLayout><LinearLayoutandroid:layout_marginTop="20dp"android:orientation="horizontal"android:layout_width="match_parent"android:layout_height="wrap_content"><Buttonandroid:id="@+id/btnzc"android:text="注  册"android:textSize="26sp"android:layout_weight="1"android:layout_marginLeft="50dp"android:background="@color/colorPrimary"android:layout_width="wrap_content"android:layout_height="wrap_content"/><Buttonandroid:id="@+id/btnqx"android:text="取  消"android:background="@color/colorPrimary"android:textSize="26sp"android:layout_weight="1"android:layout_marginLeft="10dp"android:layout_marginRight="50dp"android:layout_width="wrap_content"android:layout_height="wrap_content"/></LinearLayout>

2、MainActivity.java

package com.example.myapp318qqreg;

import androidx.appcompat.app.AppCompatActivity;

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

public class MainActivity extends AppCompatActivity {
//定义对象
EditText etName,etPwd;
Button btnZC,btnQX;

@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);//实例化对象,将XML中的组件,强类型转批为java中的对象,才可以调用对象的事件方法etName=(EditText)findViewById(R.id.etname);etPwd=(EditText)findViewById(R.id.etpwd);btnZC=(Button)findViewById(R.id.btnzc);btnQX=(Button)findViewById(R.id.btnqx);//编写按钮的监听事件btnZC.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {//获取注册信息,账号和密码的内容,定义了字符缓冲对象if(!etName.getText().toString().trim().equals("") && !etPwd.getText().toString().trim().equals("")) {StringBuffer str = new StringBuffer("你QQ注册的信息如下:\n");str.append("账号:" + etName.getText().toString().trim()).append("\n");str.append("密码:" + etPwd.getText().toString().trim());//定义意图Intent,并写入数据putExtra()Intent intent = new Intent(MainActivity.this, SuccessRegActivity.class);intent.putExtra("reginfo", str.toString());//键、值对//启动意图startActivity(intent);finish();}else{Toast.makeText(MainActivity.this,"账号和密码不能为空!",Toast.LENGTH_SHORT).show();}}});btnQX.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View v) {etName.setText("");etPwd.setText("");}});}

}

**

3、activity_success_reg.xml

<?xml version="1.0" encoding="utf-8"?>

<TextViewandroid:id="@+id/tv"android:text="注册的QQ信息:"android:layout_marginTop="70dp"android:layout_gravity="center"android:textSize="30sp"android:textColor="@color/colorAccent"android:layout_width="wrap_content"android:layout_height="wrap_content" /><Buttonandroid:id="@+id/btnback"android:text="返   回"android:textSize="26sp"android:layout_marginTop="150dp"android:layout_gravity="center"android:onClick="doClick"android:layout_width="wrap_content"android:layout_height="wrap_content"/>

*4、SuccessRegActivity.java

package com.example.myapp318qqreg;

import androidx.appcompat.app.AppCompatActivity;

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

public class SuccessRegActivity extends AppCompatActivity {
TextView tV;

@Override
protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_success_reg);tV=(TextView)findViewById(R.id.tv);Intent intent=getIntent();String  xx=intent.getStringExtra("reginfo");//获取上一界面中,指定的键reginfotV.setText(xx);//将intent获取的内容,赋值给tV}public  void doClick(View v){Intent intent=new Intent(SuccessRegActivity.this,MainActivity.class);startActivity(intent);finish();}

}

2021-06-07 QQ注册相关推荐

  1. 【重磅最新】163篇ICML-2021强化学习领域论文整理汇总(2021.06.07)

    深度强化学习实验室 官网:http://www.neurondance.com/ 论坛:http://deeprl.neurondance.com/ 作者:深度强化学习实验室 来源:整理自https: ...

  2. 公安部82号令学习----2021.06.07

    所有内容仅供学习使用,切勿用于商业用途 若有不妥之处,望各位大佬指出,小弟虚心请教 名词解释 互联网服务提供者(ISP):互联网运营商.电信.移动.联通.铁通等 联网使用单位:医院.学校.政府.机构等 ...

  3. 强化学习读书笔记 - 06~07 - 时序差分学习(Temporal-Difference Learning)

    强化学习读书笔记 - 06~07 - 时序差分学习(Temporal-Difference Learning) 学习笔记: Reinforcement Learning: An Introductio ...

  4. Mculover666的博客文章导航(嵌入式宝藏站)(2021.06.17更新)

    一.MCU系列 1. 开发环境 [Keil MDK](一)Keil MDK 5.28 的下载.安装.破解 [Keil MDK](二)Keil MDK中芯片器件包的安装 [Keil MDK](三)Kei ...

  5. web练习一——qq注册面开发(四)源码

    html部分: <!DOCTYPE html> <html><head><meta charset="utf-8" /><ti ...

  6. HTML期末网页作业-仿QQ官网QQ注册网页

    HTML期末作业-仿QQ官网QQ注册网页(HTML+CSS+JavaScript) 学生作业仿QQ官网部分代码截图 <!DOCTYPE html> <html lang=" ...

  7. QQ注册时间查询非常准确源码程序

    介绍: 由于腾讯官方并未给出专门的qq注册时间查询入口,所以用户需要借助其他服务进行查询,这个查询来源并非是QQ秀资料里显示QQ注册日期,也不是Q年龄来计算注册时间的,Q秀资料注册时间和Q龄并不是准确 ...

  8. QQ注册页面(完整版)

    前言 最近学了一点HTML和CSS的基础知识,于是就做了一个QQ注册页面来检验一下成果. 一.效果展示 二. 代码展示 1.HTML部分 <!DOCTYPE html> <html ...

  9. 2021.06.03邮票面值设计

    2021.06.03邮票面值设计 题目描述 给定一个信封,最多只允许粘贴 N 张邮票,计算在给定 K(N+K≤15)种邮票的情况下(假定所有的邮票数量都足够),如何设计邮票的面值,能得到最大值 MAX ...

最新文章

  1. 将文件名发送到服务器,将Paperclip路径文件名从服务器更新到s3(Updating Paperclip path file names from on server to s3)...
  2. MRP区域“MRP Area”的定义以及作用
  3. JZOJ__Day 2:【NOIP普及模拟】分数
  4. C++ String类写时拷贝 4
  5. [html] title与h1、b与strong、i与em的区别分别是什么?
  6. 代码面试最常用的10大算法
  7. ZZULIOJ 1103: 平均学分绩点(函数专题)
  8. Java的synchronized的使用_Java中synchronized的用法
  9. 把python37添加到环境变量配置_linux设置python环境变量 分类: python ...
  10. vb中findwindow的疑惑
  11. 模电里的时变信号直流信号交流信号字母大小写的规定
  12. LeetCode(26): 删除排序数组中的重复项
  13. 关于VS编译的程序内存分配只能用1.5~2G上限的优化方案
  14. 强化学习在生成对抗网络文本生成中扮演的角色
  15. F - Pasha and Phone CodeForces - 595B(数学)
  16. Markdown编辑器使用-yellowcong
  17. solr6.2从环境部署到与mysql整合到中文分词器到solrJ的使用
  18. 关于swiftUI和UIKit混用
  19. html5 生成条码,Html5添加Canvas的EAN13条形码生成插件教程
  20. 数据库学习-三种异常

热门文章

  1. html网页如何在手机上观看,电脑的html怎么在手机观看
  2. AMD重新进入核心竞争领域
  3. 星宸科技IC2020笔试
  4. java递归函数返回值_java基础5(方法、有无返回值、重载、递归)
  5. android rn动态技术,ReactNative入门之android与rn初始化参数的传递
  6. 网络学习-6.VLAN
  7. nodejs服务器与服务器之间通讯问题(nodejs服务器端创建客户端)
  8. 如何挽救婚姻?不想离婚就做好这8个方面,分分钟留下她
  9. QVariant方法功能(QT5.12)
  10. nodejs npm报错 重装 解决方法