1.依赖
implementation ‘com.google.code.gson:gson:2.8.5’
2.主函数的布局(登录页面)
<?xml version="1.0" encoding="utf-8"?><EditText
android:id="@+id/login_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入手机号"
android:padding="10dp" />
<EditText
android:id="@+id/login_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录" />
3.登录的主函数代码LoginMainActivity
package com.example.day07mvc;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.os.Handler;
import android.os.Message;
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 com.example.day07mvc.bean.User;
import com.example.day07mvc.core.DataCall;
import com.example.day07mvc.dao.Dao;
import com.example.day07mvc.http.Utils;
import com.example.day07mvc.model.LoginModel;
import com.example.day07mvc.presenter.LoginPresenter;
public class LoginMainActivity extends AppCompatActivity implements View.OnClickListener,DataCall {
//继承接口DataCall
private EditText login_phone;
private EditText login_pwd;
private Button login;
// private LoginModel loginModel;
private LoginPresenter loginPresenter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Dao dao = new Dao(this);
Cursor cursor = dao.selete("user&