首页 > 其他分享 >Android学习-每日打卡APP-实现浏览功能

Android学习-每日打卡APP-实现浏览功能

时间:2023-03-05 21:57:57浏览次数:36  
标签:log APP id import et 打卡 btn Android view

接着写每日打卡App

现在实现了浏览功能

package com.example.clockappliction;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.clockappliction.DataBase.CRUD;
import com.example.clockappliction.Information.Student;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_login, btn_reg,btn_list;

    private EditText et_log_id,et_log_name,et_log_grade,et_log_phone;

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

        btn_login = (Button) findViewById(R.id.btn_login);
        btn_login.setOnClickListener(this);

        btn_reg = (Button) findViewById(R.id.btn_reg);
        btn_reg.setOnClickListener(this);

        btn_list = (Button) findViewById(R.id.btn_list);
        btn_list.setOnClickListener(this);

        et_log_id = (EditText) findViewById(R.id.et_log_id);
        et_log_name = (EditText) findViewById(R.id.et_log_name);
        et_log_grade = (EditText) findViewById(R.id.et_log_grade);
        et_log_phone = (EditText) findViewById(R.id.et_log_phone);

    }

    @Override
    public void onClick(View view) {

        if (view == findViewById(R.id.btn_login)){

            Student student = new Student();
            CRUD crud = new CRUD(this);
            //获取输入框的学生信息
            student.id = et_log_id.getText().toString();
            student.name = et_log_name.getText().toString();
            student.grade = et_log_grade.getText().toString();
            student.phone = et_log_phone.getText().toString();
            //通过id获取数据库学生信息
            Student studentData =crud.getStudentById(student.id);
            //登录
            if (student.id.equals(studentData.id)){
                if (student.name.equals(studentData.name)){
                    if (student.grade.equals(studentData.grade)){
                        if (student.phone.equals(studentData.phone)){
                            Intent intent =new Intent(this,MenuActivity.class);
                            intent.putExtra("st_id",student.id);
                            intent.putExtra("st_name",student.name);
                            startActivity(intent);
                        }else {
                            Toast.makeText(this, "电话号码不正确", Toast.LENGTH_SHORT).show();
                        }
                    }else {
                        Toast.makeText(this, "班级不正确", Toast.LENGTH_SHORT).show();
                    }
                }else {
                    Toast.makeText(this, "姓名不正确", Toast.LENGTH_SHORT).show();
                }
            }else {
                Toast.makeText(this, "学号不正确", Toast.LENGTH_SHORT).show();
            }

        } else if (view == findViewById(R.id.btn_reg)) {
            //跳转到注册页面
            Intent intent = new Intent(this,RegActivity.class);
            intent.putExtra("keys",0);
            startActivity(intent);
        } else if(view == findViewById(R.id.btn_list)){
            Intent intent = new Intent(this,ListActivity.class);

            startActivity(intent);
        }


    }

}
package com.example.clockappliction;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MyListAdapter extends BaseAdapter {

    private Context mContext;
    private LayoutInflater mLayoutInflater;
    public MyListAdapter(Context context){
        this.mContext = context;
        mLayoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        return 10;
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    static class ViewHolder{
        public TextView tv1,tv2,tv3,tv4;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null){
            view = mLayoutInflater.inflate(R.layout.layout_list_item,null);
            holder =  new ViewHolder();

            holder.tv1 = (TextView) view.findViewById(R.id.tv_1);
            holder.tv2 = (TextView) view.findViewById(R.id.tv_2);
            holder.tv3 = (TextView) view.findViewById(R.id.tv_3);
            holder.tv4 = (TextView) view.findViewById(R.id.tv_4);

            view.setTag(holder);
        }else{
            holder = (ViewHolder)view.getTag();
        }
        holder.tv1.setText("日期:");
        holder.tv2.setText("关键字:");
        holder.tv3.setText("总结:");
        holder.tv4.setText("坚持天数:");

        return view;
    }

}

 

标签:log,APP,id,import,et,打卡,btn,Android,view
From: https://www.cnblogs.com/rsy-bxf150/p/17181790.html

相关文章

  • APP学习7(自定义view)
    1.自定义view当系统控件不能满足需求是,需要自定义控件。自定义View常用的3个方法:onMeasure()方法:测量尺寸。onDraw()方法:绘制图像。onLayout()方法:指定布局中控件的......
  • APP学习6(RecycleView)
    1.RecycleViewAndroid5.0之后提供的用于在有限的窗口范围内显示大量数据的控件。与ListView相比,展示效果、适配器更好。代码:activity_main.xml<?xmlversion="1.0"......
  • spring找不到配置文件applicationContext.xml
    问题描述:报错信息为Causedby:java.io.FileNotFoundException:classpathresource[applicationContext.xml]cannotbeopenedbecauseitdoesnotexisttarget目......
  • 3月5号Android学习
    <?xmlversion="1.0"encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools......
  • 浏览器控制台Application的local storage和session storage区别
    以下仅作为个人学习使用:(1)localStorage:仅在客户端(浏览器)中保存,不参与服务器的通信.设置:localStorage.setItem('Token',JSON.stringify(res.data))获取:localStorage.g......
  • 【Android逆向】脱壳项目 frida-dexdump 原理分析
    1.项目代码地址https://github.com/hluwa/frida-dexdump2.核心逻辑为defdump(self):logger.info("[+]Searching...")st=time.time()......
  • APP学习5(ListView和Adapter)
    1.ListViewListView是以列表的形式展示数据内容,并且能够根据列表的高度自适应屏幕显示。   2.常用数据适配器(Adapter)BaseAdapter是基本的适配器,实际上是一个抽......
  • Android学习-ListView再视
    之前接触了一点ListView的基础知识,但没有自己去敲,学的不是很深刻,今天我按照教程,写了一个listview的基本实现,基本掌握了listviewlistview的学习是为了给RecyclerView打一下......
  • 【Android逆向】脱壳项目frida_dump 原理分析
    脱dex核心文件dump_dex.js核心函数functiondump_dex(){varlibart=Process.findModuleByName("libart.so");varaddr_DefineClass=null;varsymbol......
  • ApplicationContext和BeanFactory
    ApplicationContext和BeanFactoryBeanFactoryBeanFactory是spring的IOC容器的核心,Spring使用BeanFactory来实例化、配置和管理Bean。常用的BeanFactory核心实现有:D......