登录注册

安卓应用登录注册界面实现

主activity.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"
    tools:context=".MainActivity">

    <EditText
        android:id="@+id/userName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入用户名"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        />

    <EditText
        android:id="@+id/pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >

        <Button
            android:id="@+id/logins"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="登录"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="10dp"
            />
        <Button
            android:id="@+id/res"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注册"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="50dp"
            />


    </LinearLayout>

</LinearLayout>

 

注册布局

<?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"
    tools:context=".ZhuCeActivity">


    <EditText
        android:id="@+id/resName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入用户名"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        />

    <EditText
        android:id="@+id/resPass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入密码"
        android:layout_marginTop="10dp"
        android:padding="10dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        >


        <Button
            android:id="@+id/zhuce"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="注册"
            android:layout_marginTop="50dp"
            android:layout_marginLeft="50dp"
            />


    </LinearLayout>

</LinearLayout>

 

 

登录presenter

package bwie.com.lenovo.day18.presenter;

import bwie.com.lenovo.day18.MainActivity;
import bwie.com.lenovo.day18.model.LoginModel;
import bwie.com.lenovo.day18.view.ILoginView;

public class LoginPresenter {

    private final LoginModel loginModel;
    ILoginView iLoginView;
    public LoginPresenter(ILoginView loginView) {

        loginModel = new LoginModel();
        iLoginView = loginView;
    }

    public void getDataPresenter(String name, String pass){
            loginModel.showDataModel(name,pass);
            loginModel.setOnLoginListener(new LoginModel.OnLoginListener() {
                @Override
                public void result(String status) {

                    iLoginView.getData(status);

                }
            });

    }

}

 

// 注册 presenter

package bwie.com.lenovo.day18.presenter;

import bwie.com.lenovo.day18.model.ZhuCeModel;
import bwie.com.lenovo.day18.view.IZhuCeView;

public class ZhuCePresenter {

    private IZhuCeView isZhuCeView;
    private final ZhuCeModel zhuCeModel;

    public ZhuCePresenter(IZhuCeView iZhuCeView) {
        isZhuCeView = iZhuCeView;
        zhuCeModel = new ZhuCeModel();

    }

    public void zhuCePreData(String name, String pass){
        zhuCeModel.zhuCeModelData(name,pass);
        zhuCeModel.setiZhuceDa(new ZhuCeModel.IZhuceDa() {
            @Override
            public void stulr(String status) {
                isZhuCeView.getDataZhuCe(status);
            }
        });
    }

}

 

 

//登录model

package bwie.com.lenovo.day18.model;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class LoginModel {

    //创建接口
    public interface OnLoginListener{
        void result(String status);
    }

    private OnLoginListener onLoginListener;

    public void setOnLoginListener(OnLoginListener onLoginListener) {
        this.onLoginListener = onLoginListener;
    }

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 0:
                    String json = (String) msg.obj;
                    Log.i("aaa",json);


                    try {
                        JSONObject jsonObject = new JSONObject(json);
                        String status = jsonObject.getString("status");

                        if (onLoginListener!=null){
                            onLoginListener.result(status);
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    break;
            }
        }
    };

    public void showDataModel(String name,String pass){

        OkHttpClient okHttpClient = new OkHttpClient();

        RequestBody requestBody = new FormBody.Builder()
                .add("phone",name)
                .add("pwd",pass)
                .build();

        Request request = new Request.Builder()
                .url("http://172.17.8.100/small/user/v1/login")
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String string = response.body().string();
                Message message = new Message();
                message.what = 0;
                message.obj = string;
                handler.sendMessage(message);

            }
        });

    }

}

 

//注册model

package bwie.com.lenovo.day18.model;

import android.os.Handler;
import android.os.Message;
import android.util.Log;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class ZhuCeModel {


    public interface IZhuceDa{
        void stulr(String status);
    }


    private IZhuceDa iZhuceDa;

    public void setiZhuceDa(IZhuceDa iZhuceDa) {
        this.iZhuceDa = iZhuceDa;
    }

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 0:
                    String json = (String) msg.obj;
                    Log.i("bbbb",json);

                    try {
                        JSONObject jsonObject = new JSONObject(json);

                        String status = jsonObject.getString("status");

                        if (iZhuceDa!=null){
                            iZhuceDa.stulr(status);
                        }

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                    break;
            }
        }
    };


    public void zhuCeModelData(String name,String pass){
        OkHttpClient okHttpClient = new OkHttpClient();

        RequestBody requestBody = new FormBody.Builder()
                .add("phone",name)
                .add("pwd",pass)
                .build();

        Request request = new Request.Builder()
                .url("http://172.17.8.100/small/user/v1/register")
                .post(requestBody)
                .build();

        okHttpClient.newCall(request).enqueue(new Callback() {
            @Override
            public void onFailure(Call call, IOException e) {

            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                String string = response.body().string();

                Message message = new Message();
                message.what=0;
                message.obj = string;
                handler.sendMessage(message);

            }
        });

    }

}

 

登录主页面

package bwie.com.lenovo.day18;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import bwie.com.lenovo.day18.presenter.LoginPresenter;
import bwie.com.lenovo.day18.view.ILoginView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener,ILoginView {

    private Button login;
    private Button res;
    private EditText name;
    private EditText pass;
    private LoginPresenter loginPresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        name = findViewById(R.id.userName);
        pass = findViewById(R.id.pass);

        login = findViewById(R.id.logins);
        res = findViewById(R.id.res);

        login.setOnClickListener(this);
        res.setOnClickListener(this);
        loginPresenter = new LoginPresenter(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){

            case R.id.logins:
                String names = name.getText().toString();
                String passs = pass.getText().toString();
                if (names.length()>=11 && passs.length()>=3){
                    loginPresenter.getDataPresenter(names,passs);

                }else {
                    Toast.makeText(this,"手机格式不对",Toast.LENGTH_SHORT).show();


                }
                break;

            case R.id.res:
                startActivity(new Intent(MainActivity.this,ZhuCeActivity.class));
                finish();
                break;
        }


    }


    @Override
    public void getData(String data) {
        int i = Integer.parseInt(data);

        if (i == 0000){
            Toast.makeText(this,"登录成功",Toast.LENGTH_SHORT).show();
            startActivity(new Intent(MainActivity.this,ShowActivity.class));
            finish();
        }else {
            Toast.makeText(this,"登录失败",Toast.LENGTH_SHORT).show();
        }

    }
}

 

 

//注册主页面

 

package bwie.com.lenovo.day18;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import bwie.com.lenovo.day18.presenter.ZhuCePresenter;
import bwie.com.lenovo.day18.view.ILoginView;
import bwie.com.lenovo.day18.view.IZhuCeView;

public class ZhuCeActivity extends AppCompatActivity implements IZhuCeView {

    private Button zhuce;
    private EditText rName;
    private EditText rPass;
    private ZhuCePresenter zhuCePresenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_zhu_ce);

        rName = findViewById(R.id.resName);
        rPass = findViewById(R.id.resPass);


        zhuce = findViewById(R.id.zhuce);
        zhuCePresenter = new ZhuCePresenter(this);

        zhuce.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String rname = rName.getText().toString();
                String rpass = rPass.getText().toString();

                if (rname.length()>=11 && rpass.length()>=3){
                    zhuCePresenter.zhuCePreData(rname,rpass);
                }else {
                    Toast.makeText(ZhuCeActivity.this,"手机格式不正确",Toast.LENGTH_SHORT).show();
                }

            }
        });
    }


    @Override
    public void getDataZhuCe(String data) {
        int i = Integer.parseInt(data);
        if (i == 0000){
            Toast.makeText(this,"注册成功",Toast.LENGTH_SHORT).show();
            startActivity(new Intent(ZhuCeActivity.this,MainActivity.class));


        }else {
            Toast.makeText(this,"此号码已被注册",Toast.LENGTH_SHORT).show();
        }
    }
}
内容概要:本文详细介绍了一个基于Java+Vue的深度学习遥感建筑物提取与变化检测系统的设计与实现。系统融合多源遥感数据预处理、U-Net建筑物分割、孪生神经网络变化检测等核心技术,构建从前端交互、后端任务调度到模型推理的完整闭环。项目涵盖需求分析、数据库设计(MySQL)、API接口规范、前后端功能模块实现(含代码示例)、系统部署与未来优化方向,实现了遥感影像上传、自动分割、多时相变化检测、结果可视化与报告导出等全流程功能。系统具备高自动化、强交互性、可扩展性和安全合规等特点,适用于城市规划、灾害监测、土地调查等多个领域。; 适合人群:具备Java、Vue前端及深度学习基础知识的研发人员、GIS开发工程师、遥感数据分析师,以及从事智慧城市、自然资源管理等相关领域的技术人员。; 使用场景及目标:①应用于城市精细化管理、灾害应急响应、房地产监控等场景,实现建筑物动态变化的智能识别与可视化分析;②作为深度学习与遥感技术融合的教学案例,帮助开发者掌握前后端分离架构、模型集成、大规模数据处理与系统部署的综合技能;③为企业或科研机构提供可二次开发的开源框架,支持定制化模型接入与业务扩展。; 阅读建议:建议结合文档中的代码示例与系统架构图进行实践,重点关注前后端交互逻辑、深度学习模型调用方式及数据库设计。在学习过程中可搭建本地开发环境,逐步实现各功能模块,并通过模拟数据验证系统流程。同时注意安全规范与性能优化策略,以提升系统的稳定性与实用性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值