体温填报app开发

设计思路:

       制作体温填报网页,利用按钮跳转。

 

 代码如下:

 

 

 

 

package com.example.myapp1;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.example.myapp1.service.UserService;

public class P extends AppCompatActivity
{
    EditText username,password;
    Button register;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_p);
        findViews();
        register.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v)
            {
                String name=username.getText().toString().trim();
                String pass=password.getText().toString().trim();
                Log.i("TAG",name+"_"+pass);
                UserService uService=new UserService(P.this);
                User user=new User();
                user.setUsername(name);
                user.setPassword(pass);
                uService.register(user);
                Toast.makeText(P.this, "注册成功", Toast.LENGTH_LONG).show();
            }
        });
    }
    private void findViews()
    {
        username=(EditText) findViewById(R.id.name);
        password=(EditText) findViewById(R.id.password);
        register=(Button) findViewById(R.id.but);
    }
}

package com.example.myapp1;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.util.Log;
import android.widget.EditText;
import android.widget.Toast;
import com.example.myapp1.service.UserService;
import android.net.Uri;

public class PageA extends AppCompatActivity
{
    Button B1,B2,B;
    EditText username,password;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_page);
        username=(EditText) findViewById(R.id.name);
        password=(EditText) findViewById(R.id.password);
        B=findViewById(R.id.b);
        B.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name=username.getText().toString();
                System.out.println(name);
                String pass=password.getText().toString();
                System.out.println(pass);
                String id="54gly",p="gly945";
                if((name.equals(id)) && (pass.equals(p)))
                {
                    Intent in=new Intent(PageA.this,P.class);
                    startActivity(in);
                }
                else
                {
                    Log.i("TAG","登录失败");
                    Toast.makeText(PageA.this, "登录失败", Toast.LENGTH_LONG).show();
                }
            }
        });
        B1=findViewById(R.id.b1);
        B1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent in=new Intent(PageA.this,PageB.class);
                startActivity(in);
            }
        });
        B2=findViewById(R.id.b2);
        B2.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View v)
            {
                String name=username.getText().toString();
                System.out.println(name);
                String pass=password.getText().toString();
                System.out.println(pass);
                Log.i("TAG",name+"_"+pass);
                UserService uService=new UserService(PageA.this);
                boolean flag=uService.login(name,pass);
                if(flag)
                {
                    final Uri uri=Uri.parse("https://www.wenjuan.com/sr/iARJnq/verify/");
                    Intent intent=new Intent(Intent.ACTION_VIEW,uri);
                    startActivity(intent);
                }
                else
                    {
                        Log.i("TAG","登录失败");
                        Toast.makeText(PageA.this, "登录失败", Toast.LENGTH_LONG).show();
                    }
            }
        });
    }
}

 

 

 

posted @ 2021-02-10 18:16  谦寻  阅读(49)  评论(0编辑  收藏  举报