android studio 连接云服务器上的mysql实现登录注册

android studio 连接云服务器上的mysql实现登录注册

我使用的是云服务器上安装的mysql 具体的安装步骤可以百度一下挺简单的,我这里就不写步骤了。当然如果你用的是本地的mysql也行,连接步骤都是一样的。

首先在android studio中导入mysql驱动包
驱动包在官网就可以下载 建议不要用8.0以上的 容易报错。
在main中新建一个libs文件然后把下载的驱动包放在libs文件中
把驱动包放在libs目录下
右击选择Add As Library
添加完成后在注册清单中增加网络权限

 <uses-permission android:name="android.permission.INTERNET" />

准备工作到这已经结束了 接下来就代码的编写 ,登录注册的界面比较简单 我就只展示注册界面(登录界面只比注册界面多了一个注册按钮)

注册界面布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
    tools:context="com.example.tt.MainActivity">

  <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginLeft="97dp"
      android:id="@+id/name"
      android:text="账号:"
      android:layout_alignParentTop="true"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_marginStart="97dp"
      android:layout_marginTop="114dp" />
<EditText
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:id="@+id/phone"
android:hint="输入手机号"
    android:textSize="13sp"
    android:background="@null"
    android:layout_alignBottom="@+id/name"
    android:layout_toRightOf="@+id/name"
    android:layout_toEndOf="@+id/name"
    android:layout_marginLeft="27dp"
    android:layout_marginStart="27dp" />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="97dp"
        android:id="@+id/mima"
        android:layout_below="@+id/name"
        android:text="密码:"
        android:layout_marginTop="14dp" />
    <EditText
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:id="@+id/password"
       android:layout_below="@+id/phone"
        android:textSize="13sp"
        android:hint="输入密码"
        android:background="@null"
      android:layout_toRightOf="@+id/mima"
        android:layout_marginTop="15dp"
        android:layout_marginLeft="27dp"
        android:layout_marginStart="27dp" />

    <
  • 9
    点赞
  • 106
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 11
    评论
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

S1om

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值