首页 > 其他分享 >今日总结

今日总结

时间:2023-02-20 23:35:01浏览次数:28  
标签:总结 public values import 今日 android null id

今天完成了app界面和注册

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="学号"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:id="@+id/id"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:inputType="number"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="用户名"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:id="@+id/name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:inputType="text"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="手机号码"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:id="@+id/phone"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:inputType="text"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="班级"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:id="@+id/unit"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:inputType="text"
        />
    <Button
        android:id="@+id/add"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="10pt"
        android:text="注册"
        />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:id="@+id/b1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:text="注册"
        android:textColor="@android:color/holo_orange_dark"
        android:textSize="20pt" />
    <Button
        android:id="@+id/b2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:text="打卡"
        android:textColor="@android:color/holo_orange_dark"
        android:textSize="20pt" />
    <Button
        android:id="@+id/b3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="20dp"
        android:text="设置事件"
        android:textColor="@android:color/holo_orange_dark"
        android:textSize="20pt" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="每日关键字"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:inputType="text"
        />
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="15dp"
        android:text="每日总结"
        android:textColor="@android:color/holo_blue_bright"
        android:textSize="8pt" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:textColor="@android:color/holo_purple"
        android:layout_margin="15dp"
        android:textSize="8pt"
        android:background="@android:drawable/edit_text"
        android:inputType="text"
        />
    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="10pt"
        android:text="增加"
        />
</LinearLayout>
package com.example.stusign;

import androidx.appcompat.app.AppCompatActivity;

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

public class MainActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       Button b1=findViewById(R.id.b1);
       b1.setOnClickListener(this);
        Button b2=findViewById(R.id.b2);
        b2.setOnClickListener(this);
        Button b3=findViewById(R.id.b3);
        b3.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.b1:
                startActivity(new Intent(MainActivity.this,ResigerActivity.class));
                break;
            case R.id.b2:
                startActivity(new Intent(MainActivity.this,SignActivity.class));
                break;
            case R.id.b3:
                break;
        }
    }
}
package com.example.stusign;


import android.content.Context;
import android.content.DialogInterface;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.example.stusign.pojo.Stu;
import com.example.stusign.utils.StuUtils;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

public class ResigerActivity extends AppCompatActivity implements View.OnClickListener {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.stu_resiger);
        Button button=findViewById(R.id.add);
        button.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        EditText editText=findViewById(R.id.id);
        int id=Integer.parseInt(editText.getText().toString());
        editText=findViewById(R.id.name);
        String name=editText.getText().toString();
        editText=findViewById(R.id.phone);
        String phone=editText.getText().toString();
        editText=findViewById(R.id.unit);
        String unit=editText.toString();
        String sqlpath=getFilesDir()+"/stu.db";
        SQLiteDatabase sqLiteDatabase=openOrCreateDatabase(sqlpath, Context.MODE_PRIVATE,null);
        AlertDialog.Builder builder=new AlertDialog.Builder(this);
        StuUtils stuUtils=StuUtils.getStuUtils(this);
        stuUtils.onCreate(sqLiteDatabase);
        builder.setTitle("注册结果");
        if(stuUtils.add(sqLiteDatabase,new Stu(id,name,phone,unit))){
            builder.setMessage("注册成功");
        }
        else{
            builder.setMessage("注册失败");
        }
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                finish();
            }
        });
        builder.show();
    }
}
package com.example.stusign.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

import com.example.stusign.pojo.Stu;

public class StuUtils extends SQLiteOpenHelper {
    private static StuUtils stuUtils;
    private static final String Name="stu";

    public static  StuUtils getStuUtils(Context context){
        if(stuUtils==null) stuUtils=new StuUtils(context);
        return stuUtils;
    }
    private StuUtils(@Nullable Context context){
        super(context,Name,null,1);
    }
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        String sql="create table stu(" +
                "id int(4) not null PRIMARY KEY," +
                "`name` varchar(10) not null," +
                "phone varchar(16) not null," +
                "unit varchar(10) not null" +
                ")";
        sqLiteDatabase.execSQL(sql);
    }
    public Boolean add(SQLiteDatabase sqLiteDatabase,Stu stu){
        ContentValues values=new ContentValues();
        values.put("id",stu.getId());
        values.put("name",stu.getName());
        values.put("phone",stu.getPhone());
        values.put("unit", stu.getUnit());
        return sqLiteDatabase.insert(Name,null,values)>0;
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}
package com.example.stusign.utils;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.stusign.pojo.Sign;

public class SignUtils extends SQLiteOpenHelper {
    private static SignUtils signUtils;
    private static final String Name="sign";
    public SignUtils getSignUtils(Context context){
        if(signUtils==null) signUtils=new SignUtils(context);
        return signUtils;
    }
    private SignUtils(Context context){
        super(context,Name,null,1);
    }
    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        String sql="create table sign(" +
                "id int(4) not null PRIMARY KEY," +
                "`date` varchar(20) not null," +
                "days int not null," +
                "longdays int not null," +
                "keywords varchar(50) not null," +
                "summary varchar(500) not null)";
        sqLiteDatabase.execSQL(sql);
    }
    public Boolean add(SQLiteDatabase sqLiteDatabase, Sign sign){
        ContentValues values=new ContentValues();
        values.put("id",sign.getId());
        values.put("date",sign.getDate());
        values.put("days",sign.getDays());
        values.put("longdays",sign.getLongdays());
        values.put("keywords",sign.getKeywords());
        values.put("summary",sign.getSummary());
     return   sqLiteDatabase.insert(Name,null,values)>0;

    }
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }
}

 

标签:总结,public,values,import,今日,android,null,id
From: https://www.cnblogs.com/liyiyang/p/17139405.html

相关文章

  • 助教工作总结
    一、助教工作的具体职责和任务在作业截至日期前通知未完成作业的同学尽快完成,并视情况给未按时提交作业的同学开启补交机会。及时批改每次作业,在云班课的评论区中指出错......
  • 2023/2/20总结
    今天王老师给我们讲了关于大学的学习历程和目标,并且用他的游泳经历联系起来,给我们讲诉了空学理论不能达成想要达到的目标,要是实践起来。......
  • 每日总结
    鉴于大二下学期徐亚需要开发APP所以又要学习新的知识,上学期主要学的是Javaweb和HTML的相关技术但是实际上涉及的层面只不过是九牛一毛很多深层的内容不够了解比如还没全......
  • 2022.2.20学习总结
    今天老师花了三节课多,也算得上是给我们打了一针鸡血,也明确的指明了我们下个阶段的学习目标,我是一个十分清楚自己想要得到什么,当下该做一些什么的人,我也找到了我下一个阶段......
  • 今日总结
    今天我们开学考不理想的进行了专项的训练,主要是从前端传输数据到数据库中,经过查阅资料捋清了主要流程,要先在页面进行输入数据,然后将页面的数据传输到另一个连接数据库的段......
  • 每日总结 --2023/2/20日
    周一上午课程:工程数学 下午课程:软件工程晚上课程:数学建模学习内容:工程数学:梯度,方向导数软件工程:总体学习方向,方法数学建模:基础数学建模问题代......
  • 算法刷题 Day 46 | ● 139.单词拆分 ● 关于多重背包,你该了解这些!● 背包问题总结篇!
    关于多重背包,力扣上没有相关的题目,所以今天大家的重点就是回顾一波自己做的背包题目吧。139.单词拆分视频讲解:https://www.bilibili.com/video/BV1pd4y147Rhhttp......
  • 2023年2月20日总结
    今天测试主要遇到的问题是jsp之间的传值。HTML界面已全部完成,并测试可以完美显示。数据库表格创建成功,数据可以存储到数据库中。但因为jsp传值的问题,浏览功能无法实现。所......
  • 今日学习总结-01
    今天创建了软件工程日报分类,从今天开始,每天写一篇博客,记录自己每天的学习历程。今天是第二周的周一,下午王老师为我们上了这半学期第二节软工课。在这节课上,王老师用很长......
  • 每日总结-23.2.20
    今日软件工程课上明确了每日写总结的目标,之后每周一到周五的软件学习进度都要写总结。今日留下了关于android开发app的作业——每日打卡app。课下我在b站找......