zoukankan      html  css  js  c++  java
  • a-5

    注册界面

    <?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:id="@+id/activity_register"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:background="@drawable/d"
        tools:context=".register">
    
        <TextView
            android:id="@+id/login_title"
            android:text="注册"
            android:layout_width="match_parent"
            android:textSize="25sp"
            android:textColor="@color/blue"
            android:layout_height="50dp"
            android:gravity="center"
            />
    
        <TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/login_title"
            >
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp">
    
            <TextView
                android:text="账号:"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                />
    
            <EditText
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:inputType="phone"
                android:layout_weight="1"
                android:textSize="20sp"
                android:ems="10"
                android:id="@+id/et_ID" />
    
        </TableRow>
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp">
    
            <TextView
                android:text="密码:"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                />
    
            <EditText
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:textSize="20sp"
                android:inputType="textPassword"
                android:ems="10"
                android:layout_weight="1"
                android:id="@+id/et_password" />
        </TableRow>
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp">
    
            <Button
                android:text="注册"
                android:textColor="@color/white"
                android:layout_weight="1"
                android:textSize="30sp"
                android:layout_gravity="center"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:id="@+id/bt_register"
                android:background="@drawable/button_shape"/>
        </TableRow>
    
    </TableLayout>
    </RelativeLayout>
    package com.example.hhh.telephone;
    
    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 register extends AppCompatActivity implements View.OnClickListener {
        private Button bt_register;
        private EditText et_ID,et_password;
        private String username,password;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_register);
    
            et_ID = (EditText) findViewById(R.id.et_ID);
            et_password = (EditText) findViewById(R.id.et_password);
            bt_register = (Button) findViewById(R.id.bt_register);
            bt_register.setOnClickListener(this);
        }
    
        @Override
        public void onClick(View view) {
            switch (view.getId()){
                case R.id.bt_register:
                    username = et_ID.getText().toString().trim();
                    password = et_password.getText().toString().trim();
                    if(username.equals("") || password.equals("")){
                        Toast.makeText(this,"请完善信息!",Toast.LENGTH_SHORT).show();
                        return;
                    }else {
    
                            userService userService = new userService(this);
                            Boolean flag = userService.CheckIsDataAlreadyInDBorNot(username);
                            if(flag==Boolean.TRUE){
                                Toast.makeText(this,"该用户已存在!",Toast.LENGTH_SHORT).show();
                                return;
                            }else {
                                user user = new user();
                                user.setUsername(username);
                                user.setPassword(password);
                                userService.register(user);
                                Toast.makeText(this,"注册成功",Toast.LENGTH_SHORT).show();
                                finish();
    
                        }
                    }
                    break;
            }
        }
    }

  • 相关阅读:
    my34_脚本冥等添加自动任务-mysql监控部署
    zabbix4.2 安装
    面试题12:字符串无重复子串的最大长度
    面试题11:二叉树的非递归前、中、后、层级遍历
    面试题10:二叉树的最大路径和
    面试题9:数组堆化、堆的插入、堆的删除、堆排序
    面试题8:无序数组的最大差值
    面试题7:判断链表是否有环,返回环的入口点
    面试题6:二叉树最近公共节点(LCA)《leetcode236》
    面试题6:二叉树转单链表
  • 原文地址:https://www.cnblogs.com/wxyailjy/p/14097448.html
Copyright © 2011-2022 走看看