当前位置: 首页 > news >正文

兴化网站建设价格/建设网站制作公司

兴化网站建设价格,建设网站制作公司,总结网站推广策划思路的内容,毕业设计代写网站一、如何跳转一个活动 左边的是本活动名称, 右边的是跳转界面活动名称 Intent intent new Intent(LoginActivity.this, RegisterActivity.class); startActivity(intent); finish(); 二、如果在不同的界面传递参数 //发送消息 SharedPreferences sharedPreferen…

一、如何跳转一个活动

左边的是本活动名称, 右边的是跳转界面活动名称

Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);
startActivity(intent);
finish();

 

二、如果在不同的界面传递参数

//发送消息
SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("username", username);
editor.putString("password", password);
editor.apply(); //接收消息
SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", MODE_PRIVATE);
String savedUsername = sharedPreferences.getString("username", "");
String savedPassword = sharedPreferences.getString("password", "");

三、如何让图片是按钮

<ImageButtonandroid:id="@+id/imageButton"android:layout_width="50dp"android:layout_height="50dp"android:src="@drawable/s7" />

四、登录界面

1、创建一个LoginActivity类,然后创建对应的界面文件.xml

2、注册登录界面,并让登录界面其成为主界面

        <activityandroid:name=".LoginActivity"android:exported="true"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:name=".MainActivity"/><activity android:name=".RegisterActivity"/>

3、书写登录界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="20dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="账号:"android:textSize="20dp"/><EditTextandroid:id="@+id/usernameEditText"android:layout_width="180dp"android:layout_height="wrap_content"android:textSize="20dp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="密码:"android:textSize="20dp"/><EditTextandroid:id="@+id/passwordEditText"android:layout_width="180dp"android:layout_height="wrap_content"android:textSize="20dp"/></LinearLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="20dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><CheckBoxandroid:id="@+id/rememberPasswordCheckbox"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="记住密码"android:layout_gravity="start"android:layout_marginStart="16dp"android:layout_marginTop="8dp"/><TextViewandroid:layout_width="80dp"android:layout_height="wrap_content"/><Buttonandroid:id="@+id/zcButton"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="点击注册" /></LinearLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="20dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><Buttonandroid:id="@+id/loginButton"android:layout_width="200dp"android:layout_height="wrap_content"android:text="确认登录" /></LinearLayout></LinearLayout>

4、书写登录活动代码

package com.example.yaodian;import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
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.Toast;import androidx.appcompat.app.AppCompatActivity;public class LoginActivity extends AppCompatActivity {EditText usernameEditText;EditText passwordEditText;Button loginButton;Button zcButton;CheckBox rememberPasswordCheckbox ;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.login);rememberPasswordCheckbox = findViewById(R.id.rememberPasswordCheckbox);usernameEditText = findViewById(R.id.usernameEditText);passwordEditText = findViewById(R.id.passwordEditText);loginButton = findViewById(R.id.loginButton);zcButton = findViewById(R.id.zcButton);loginButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {String inputUsername = usernameEditText.getText().toString();String inputPassword = passwordEditText.getText().toString();SharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", MODE_PRIVATE);String savedUsername = sharedPreferences.getString("username", "");String savedPassword = sharedPreferences.getString("password", "");// 在这里添加登录验证逻辑if (inputUsername.equals(savedUsername) && inputPassword.equals(savedPassword)) {Toast.makeText(LoginActivity.this, "登录成功", Toast.LENGTH_SHORT).show();Intent intent = new Intent(LoginActivity.this, MainActivity.class);startActivity(intent);finish();// 跳转到 MainActivity 或其他操作} else {new AlertDialog.Builder(LoginActivity.this).setTitle("提示").setMessage("登录失败,用户名或密码错误").setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {}}).show();}}});zcButton.setOnClickListener((l) -> {Intent intent = new Intent(LoginActivity.this, RegisterActivity.class);startActivity(intent);finish();});//        // 监听复选框状态变化
//        rememberPasswordCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
//            @Override
//            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//                // 根据复选框状态来处理记住密码逻辑
//                if (isChecked) {
//
//                } else {
//
//                }
//            }
//        });}
}

五、注册界面

同登录界面

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><TextViewandroid:layout_width="wrap_content"android:layout_height="20dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="       账号:"android:textSize="20dp"/><EditTextandroid:id="@+id/usernameEditText"android:layout_width="180dp"android:layout_height="wrap_content"android:textSize="20dp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="       密码:"android:textSize="20dp"/><EditTextandroid:id="@+id/passwordEditText"android:layout_width="180dp"android:layout_height="wrap_content"android:textSize="20dp"/></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="确认密码:"android:textSize="20dp"/><EditTextandroid:id="@+id/password2EditText"android:layout_width="180dp"android:layout_height="wrap_content"android:textSize="20dp"/></LinearLayout><TextViewandroid:layout_width="wrap_content"android:layout_height="50dp"/><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="horizontal"android:gravity="center"><Buttonandroid:id="@+id/registerButton"android:layout_width="200dp"android:layout_height="wrap_content"android:text="确认注册" /></LinearLayout></LinearLayout>
package com.example.yaodian;import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;import androidx.appcompat.app.AppCompatActivity;public class RegisterActivity extends AppCompatActivity {private EditText usernameEditText;private EditText passwordEditText;private EditText password2EditText;private Button registerButton;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.register_activity);usernameEditText = findViewById(R.id.usernameEditText);passwordEditText = findViewById(R.id.passwordEditText);password2EditText = findViewById(R.id.password2EditText);registerButton = findViewById(R.id.registerButton);registerButton.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {String username = usernameEditText.getText().toString().trim();String password = passwordEditText.getText().toString().trim();String password2 = password2EditText.getText().toString().trim();if (username.isEmpty() || password.isEmpty()) {// 弹出“请输入账号和密码”的对话框new AlertDialog.Builder(RegisterActivity.this).setTitle("提示").setMessage("请输入账号和密码").setPositiveButton("确定", null).show();} else if (!password.equals(password2)) {// 弹出“两次密码不一样,请重新输入”的对话框new AlertDialog.Builder(RegisterActivity.this).setTitle("提示").setMessage("两次密码不一样,请重新输入").setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// 清空密码和确认密码输入框passwordEditText.setText("");password2EditText.setText("");}}).show();} else {// 保存注册信息到 SharedPreferencesSharedPreferences sharedPreferences = getSharedPreferences("MyPrefs", MODE_PRIVATE);SharedPreferences.Editor editor = sharedPreferences.edit();editor.putString("username", username);editor.putString("password", password);editor.apply();Toast.makeText(RegisterActivity.this, "注册成功", Toast.LENGTH_SHORT).show();Intent intent = new Intent(RegisterActivity.this, LoginActivity.class);startActivity(intent);finish();}}});}
}

六、完整工程代码

链接:https://pan.baidu.com/s/13tm-AsAsJEmfJjbwyX0a3Q
提取码:生日

需要提取码的 加QQ:1482728006,说明来意,付费即可获取工程

相关文章:

安卓如何书写注册和登录界面

一、如何跳转一个活动 左边的是本活动名称&#xff0c; 右边的是跳转界面活动名称 Intent intent new Intent(LoginActivity.this, RegisterActivity.class); startActivity(intent); finish(); 二、如果在不同的界面传递参数 //发送消息 SharedPreferences sharedPreferen…...

黄仁勋的AI时代:英伟达GPU革命的狂欢与挑战

在最近的COMPUTEX 2024大会上&#xff0c;英伟达创始人黄仁勋发布了最新的Blackwell GPU。这次发布不仅标志着英伟达在AI领域的又一次飞跃&#xff0c;也展示了其对未来技术发展的战略规划。本文将详细解析英伟达最新技术的亮点&#xff0c;探讨其在AI时代的市场地位和未来挑战…...

Linux云计算架构师涨薪班课程内容包含哪些?

第一阶段&#xff1a;Linux云计算运维初级工程师 目标 云计算工程师&#xff0c;Linux运维工程师都必须掌握Linux的基本功&#xff0c;这是一切的根本&#xff0c;必须全部掌握&#xff0c;非常重要&#xff0c;有了这些基础&#xff0c;学习上层业务和云计算等都非常快&#x…...

c语言:自定义类型(枚举、联合体)

前言&#xff1a; c语言中中自定义类型不仅有结构体&#xff0c;还有枚举、联合体等类型&#xff0c;上一期我们详细讲解了结构体的初始化&#xff0c;使用&#xff0c;传参和内存对齐等知识&#xff0c;这一期我们来介绍c语言中的其他自定义类型枚举和联合体的知识。 1.位段 …...

2024年适合GISer参加的全国性比赛

作为一名GISer&#xff0c;在校期间参加GIS比赛&#xff0c;不仅能够锻炼和提升自己的GIS专业水平&#xff0c;例如软件操作、开发能力等&#xff1b;还能加强自己团队协作能力、组织能力和沟通能力&#xff0c;此外&#xff0c;还可以给简历加分&#xff0c;增强职场竞争力。 …...

番外篇-用户购物偏好标签BP-推荐算法ALS

引言 推荐系统式信息过载所采用的措施&#xff0c;面对海量的数据信息&#xff0c;从中快速推荐出符合用户特点的物品。 推荐系统是自动化的通过分析用户对历史行为数据&#xff0c;完成用户的个性化建模&#xff0c;从而主动给用户推荐能够满足他们兴趣和需求的软件系统。 数…...

气膜体育馆的防火性能分析—轻空间

随着现代体育事业的蓬勃发展&#xff0c;气膜体育馆因其建设快捷、成本低廉、使用灵活等优势&#xff0c;逐渐在全球范围内受到广泛关注。然而&#xff0c;对于这种新型建筑形式&#xff0c;防火性能一直是人们关注的焦点之一。轻空间将详细探讨气膜体育馆的防火性能&#xff0…...

什么台灯对眼睛好?一文给你分享具体什么台灯对眼睛好!

什么台灯对眼睛好&#xff1f;随着学生们最近陆续返校&#xff0c;家长们和孩子们都忙于开学初的准备工作&#xff0c;而眼睛的健康自然也是他们考虑的一部分。这也是护眼台灯在近年来变得非常普及的原因之一。我自己一直是一个近视的人&#xff0c;而且日常用眼时间也相当长。…...

python-bert模型基础笔记0.1.00

python-bert模型基础笔记0.1.00 bert的适合的场景bert多语言和中文模型bert模型两大类官方建议模型模型中名字的含义标题bert系列模型包含的文件bert系列模型参数参考链接bert的适合的场景 裸跑都非常优秀,句子级别(例如,SST-2)、句子对级别(例如MultiNLI)、单词级别(例…...

STM32G030C8T6:EEPROM读写实验(I2C通信)--M24C64

本专栏记录STM32开发各个功能的详细过程&#xff0c;方便自己后续查看&#xff0c;当然也供正在入门STM32单片机的兄弟们参考&#xff1b; 本小节的目标是&#xff0c;系统主频64 MHZ,采用高速外部晶振&#xff0c;实现PB11,PB10 引脚模拟I2C 时序&#xff0c;对M24C08 的EEPRO…...

opencascade 布尔运算笔记

BRepAlgoAPI_Common 对两个topods求解 没有公共部分也返回结果了 我想要的结果是没有公共部分返回false 在 Open CASCADE 中使用 BRepAlgoAPI_Common 进行布尔操作时&#xff0c;即使两个 TopoDS_Shape 没有公共部分&#xff0c;操作仍会返回一个结果。为了判断两个形状是否确…...

GPT-4o:人工智能新纪元的突破与展望

&#x1f49d;&#x1f49d;&#x1f49d;欢迎来到我的博客&#xff0c;很高兴能够在这里和您见面&#xff01;希望您在这里可以感受到一份轻松愉快的氛围&#xff0c;不仅可以获得有趣的内容和知识&#xff0c;也可以畅所欲言、分享您的想法和见解。 推荐:kwan 的首页,持续学…...

标准化、信息化、数字化、智能化、智慧化与数智化

近年来&#xff0c;标准化、信息化、数字化、智能化、智慧化以及数智化等词汇频繁出现&#xff0c;并逐渐成为业界热议的焦点。在国内&#xff0c;以华为、BAT等为代表的领军企业&#xff0c;不断强调“数字化转型”的重要性&#xff0c;并致力于推动其深入实施。与此同时&…...

14-JavaScript中的点操作符与方括号操作符

JavaScript中的点操作符与方括号操作符&#xff1a;简单理解与应用 笔记分享 在JavaScript中&#xff0c;访问对象的属性有两种常见方式&#xff1a;点操作符&#xff08;.&#xff09;和方括号操作符&#xff08;[]&#xff09;。尽管它们在很多情况下可以互换使用&#xff0…...

智慧大屏是如何实现数据可视化的?

智慧大屏&#xff0c;作为数据可视化的重要载体&#xff0c;已在城市管理、交通监控、商业运营等领域广泛应用。本文旨在阐述智慧大屏实现数据可视化的关键技术和方法&#xff0c;包括数据源管理、数据处理、视觉编码、用户界面与交互设计等。 大屏通过接入企业内部的数据库系…...

【JVM精通之路】垃圾回收-三色标记算法

首先预期你已经基本了解垃圾回收的相关知识&#xff0c;包括新生代垃圾回收器&#xff0c;老年代垃圾回收器&#xff0c;以及他们的算法&#xff0c;可达性分析等等。 先想象一个场景 最开始黑色节点是GC-Roots的根节点&#xff0c;这些对象有这样的特点因此被选为垃圾回收的根…...

Redis缓存(笔记一:缓存介绍和数据库启动)

目录 1、NoSQL数据库简介 2、Redis介绍 3、Redis(win系统、linux系统中操作) 3.1 win版本Redis启动 3.2 linux版本Redis启动 1、NoSQL数据库简介 技术的分类&#xff1a;&#xff08;发展史&#xff09; 1、解决功能性的问题&#xff1a;Java、Jsp、RDBMS、Tomcat、HTML、…...

OrangePi Kunpeng Pro套装测评:开箱与基本功能测试

前言 大家好&#xff0c;我是起个网名真难。非常荣幸受到香橙派的邀请&#xff0c;同时也是第一次做这个事情&#xff0c;很荣幸对香橙派与华为鲲鹏在2024年5月12日联合发布的新品——香橙派Kunpeng Pro开发板进行深入的评测。这款开发板是香橙派与华为鲲鹏合作推出的高性能平…...

RocketMQ教程(二):RocketMQ以及控制台的安装

RocketMQ-Console RocketMQ-Console 是一个针对 Apache RocketMQ 的开源 Web 监控和管理平台。它提供了一个用户友好的界面,通过 Web 浏览器允许用户对 RocketMQ 集群进行管理和监控。这个控制台使得管理和监测 RocketMQ 集群变得更加直观和方便,特别是对于不熟悉命令行操作的…...

电脑记事本怎么恢复之前的内容记录

每个人都曾有过这样的时刻——在记事本上精心记录下的重要内容&#xff0c;一不小心就被删除了。那种心情&#xff0c;仿佛一瞬间从山顶跌落到谷底&#xff0c;无尽的懊悔涌上心头。我也曾遭遇过这样的困境&#xff0c;那些消失的文字对我来说意义非凡&#xff0c;它们的丢失仿…...

Windows下设置pip代理(proxy)

使用场景 正常网络情况下我们安装如果比较多的python包时&#xff0c;会选择使用这种 pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-hostpypi.tuna.tsinghua.edu.cn 国内的镜像来加快下载速度。 但是&#xff0c;当这台被限制上…...

【调试笔记-20240530-Linux-在 OpenWRT-23.05 上为 nginx 配置 HTTPS 网站】

调试笔记-系列文章目录 调试笔记-20240530-Linux-在 OpenWRT-23.05 上为 nginx 配置 HTTPS 网站 文章目录 调试笔记-系列文章目录调试笔记-20240530-Linux-在 OpenWRT-23.05 上为 nginx 配置 HTTPS 网站 前言一、调试环境操作系统&#xff1a;OpenWrt 23.05.3调试环境调试目标…...

安装 hbase(伪分布式)

目录 1、安装 jdk8 &#xff08;1&#xff09;选择 jdk 版本 &#xff08;2&#xff09;下载 jdk 并解压 &#xff08;3&#xff09;配置环境变量 2、安装hadoop &#xff08;1&#xff09;添加 hadoop 用户&#xff0c;配置免密登录 &#xff08;2&#xff09;下载 hado…...

Angular-数组循环

简单数组 .ts-定义一个数组 // 第一种定义方式 public arr1:string[] [aa,bb,cc]; // 完整版 arr2:string[] [aa,bb,cc]; // 省略版 public objects:any[] [{username:Echoo,age:18},{username:Amily,age:39},{username:Mike,age:34}]; // 元素是对象 //第二种定…...

初级网络工程师之入门到入狱(一)

本文是我在学习过程中记录学习的点点滴滴&#xff0c;目的是为了学完之后巩固一下顺便也和大家分享一下&#xff0c;日后忘记了也可以方便快速的复习。 网络工程师从入门到入狱 前言一、交换机二、路由器三、DHCP&#xff08;动态主机配置协议&#xff09;四、路由器配置 DHCP自…...

数据挖掘与机器学习——分类算法

目录 机器学习算法最普通分类&#xff1a; 分类算法的定义&#xff1a; 分类算法的应用&#xff1a; 分类器实现分类&#xff1a; 分类器的构建标准&#xff1a; 概率模型&#xff1a; 贝叶斯公式&#xff1a; 朴素贝叶斯算法&#xff08;朴素贝叶斯分类器&#xff09;…...

变压器励磁涌流MATLAB仿真模型

微❤关注“电气仔推送”获得资料&#xff08;专享优惠&#xff09; 变压器励磁涌流的产生机理 1、变压器是电力系统的关键部分&#xff0c;在实际的 运行中&#xff0c;变压器需要进行相应的充电&#xff0c;而在充电的过 程中&#xff0c;就需要进行开合闸作业。在开合闸作业…...

ToxVidLLM:一个用于检测有害视频的多模态多任务框架

在一个社交媒体平台赋予用户成为内容创作者力量的时代&#xff0c;数字领域见证了前所未有的信息传播激增&#xff0c;到2023年&#xff0c;近82%的互联网流量是视频内容。因此&#xff0c;像抖音和YouTub这样的平台已经成为主要的信息来源。一个显著的统计数据凸显了这些平台的…...

比较(二)利用python绘制雷达图

比较&#xff08;二&#xff09;利用python绘制雷达图 雷达图&#xff08;Radar Chart&#xff09;简介 雷达图可以用来比较多个定量变量&#xff0c;也可以用于查看数据集中变量的得分高低&#xff0c;是显示性能表现的理想之选。缺点是变量过多容易造成阅读困难。 快速绘制…...

Visual Studio怎么用?

Visual Studio的使用涉及多个方面&#xff0c;以下是一个清晰的使用指南&#xff0c;涵盖了Visual Studio的基本功能、安装、界面介绍、项目创建、代码编写、调试和发布等关键步骤&#xff1a; 一、Visual Studio简介 Visual Studio是由微软公司开发的一款集成开发环境&#…...