首页 > 其他分享 >简单记事本app2

简单记事本app2

时间:2023-03-18 23:34:02浏览次数:35  
标签:lg layout app2 match 简单 et android id 记事本

——注册——

activity_login.xml 注册页面设计

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="@color/yellow"
tools:context=".MainActivity">

<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="OvO"
android:textColor="@color/orange"
android:textSize="35sp"
android:gravity="center"
android:layout_marginTop="100dp"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="30dp">
<EditText
android:id="@+id/lg_et_name"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16sp"
android:textColor="@color/black"
android:hint=" 用户名"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/lg_et_password"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 密 码"
android:inputType="textPassword"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/lg_et_phone"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 电话号"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/lg_et_uno"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 学生/教师"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/lg_et_id"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 学号/教师编号"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
<EditText
android:id="@+id/lg_et_classs"
android:layout_width="match_parent"
android:layout_height="50dp"
android:textSize="16dp"
android:textColor="@color/black"
android:hint=" 班级/用户单位"
android:layout_marginTop="5dp"
android:maxLines="1"
android:background="@drawable/bg_frame"
/>
</LinearLayout>

<Button
android:id="@+id/lg_btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册"
android:textColor="@color/black"
android:background="@drawable/bg_frame"
android:layout_marginLeft="2dp"
android:layout_marginTop="50dp"
/>

</LinearLayout>

LoginActivity.java 注册界面后台代码,注册成功之后会跳回到登录界面

package com.example.text002;

import static db.DBManager.getUserlogin;
import static db.DBManager.getUserstart;

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 LoginActivity extends AppCompatActivity implements View.OnClickListener {

private EditText lgid, lgname, lgpassword, lgphone, lgclasss, lguno;
private Button lg_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
lgfind();
}

private void lgfind() {
lgid = findViewById(R.id.lg_et_id);
lgname = findViewById(R.id.lg_et_name);
lgpassword = findViewById(R.id.lg_et_password);
lgphone = findViewById(R.id.lg_et_phone);
lgclasss = findViewById(R.id.lg_et_classs);
lguno = findViewById(R.id.lg_et_uno);

lg_login = findViewById(R.id.lg_btn_login);
lg_login.setOnClickListener(this);
}

@Override
public void onClick(View view) {
int lg_vid = view.getId();
if(lg_vid == R.id.lg_btn_login){
//注册
String lguid = lgid.getText().toString();
String lguname = lgname.getText().toString();
String lgupassword = lgpassword.getText().toString();
String lguphone = lgphone.getText().toString();
String lguclasss = lgclasss.getText().toString();
String lgunos = lguno.getText().toString();
// insert into user (id, name, uno, classs, phone, password)
Boolean flag = getUserlogin(lguid, lguname, lgunos, lguclasss, lguphone, lgupassword);
if(flag){
Toast.makeText(this,"注册成功OvO",Toast.LENGTH_SHORT).show();
Intent intent = new Intent(LoginActivity.this,MainActivity.class);
startActivity(intent);
} else {
Toast.makeText(this,"注册失败TAT",Toast.LENGTH_SHORT).show();
}

}
}
}

下一篇写登录之后

标签:lg,layout,app2,match,简单,et,android,id,记事本
From: https://www.cnblogs.com/yansans/p/17232188.html

相关文章

  • 简单记事本app3
    ——登录之后——activity_function.xml   ListView实现滚动浏览,不过这一部分还没做完,目前浏览操作还没有连接上数据库<?xmlversion="1.0"encoding="utf-8"?><Li......
  • 简单的记事本app1
    (因为时间原因功能尚不全面,之后会继续更新)放一下目录结构,大体会用到这些——(有对应activity.xxx.xml的,创建的时候要创建activity,不要单独创建java文件)   ——这一篇......
  • nchan 集成keydb简单测试&一些说明
    因为keydb是完整兼容redis的,所以对于单机版本的兼容是很简单的,配置就行了参考单机运行docker-compose文件version:'3'services:db3:imag......
  • maven的原理、配置与简单应用
    目录1Java中的依赖和jar文件2依赖仓库的设计与实现3maven项目 - 3.1maven的配置:配置settings.xml、建立本地仓库目录maven-repo - 3.2maven的使用:以Spring......
  • 【基础算法】简单排序-冒泡排序
    【基础算法】简单排序-冒泡排序BubbleSortisthesimplestsortingalgorithmthatworksbyrepeatlyswappingtheadjacentelementsiftheyareinthewrongorde......
  • 一次简单的性能测试记录
     性能测试1.性能测试的场景:对性能压测接口:抢购进行测试 过程:刚开始没有提供接口,自己去页面抓包然后通过登录接口获取token才能去验证"藏品详情""藏品列......
  • 简单高效的打字学习软件:Master of Typing 3 Mac版
    想要提升打字速度,一款好用的打字学习软件必不可少,今天推荐MasterofTyping3Mac版给大家,一款帮助用户提高打字技巧的打字游戏。它具有不同难度级别的多个级别,可以测试和......
  • REST风格下的SpringMVC简单响应方法
    学习中,如有错误请见谅  项目结构   ServletContainersInitConfigpublicclassServletContainersInitConfigextendsAbstractAnnotationConfigDispatcher......
  • 【Android 逆向】【攻防世界】app2
    1.手机安装apk,随便点击,进入到第二个页面就停了2.jadx打开apk,发现一共有三个activity,其中第三个activity:FileDataActivity里面有东西publicclassFileDataActivitye......
  • SpringMVC 简单响应
    学习中,如有错误请多包涵项目结构  @Configuration@ComponentScan("com.itheima.controller")//开启json数据类型自动转换@EnableWebMvcpublicclassSpringMvc......