接着写每日打卡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