zoukankan      html  css  js  c++  java
  • 每日总结

      昨天对实现功能的思路进行了分析,今天就对昨天的设计进行功能的实现,首先要将数据表新增加一个用来代表班级,

    db.execSQL("create table ban(renshu char(50), banji char(20))");
    然后就是在注册界面进行修改,在注册的时候同时向班级的数据表进行信息的添加或修改
    然后重要的就是对于信息的查看读取,这就需要再写一个Activity用户统计班级的信息,
    代码如下:ublic class HUIZONG extends AppCompatActivity {
       private DataBase databaseHelper; //用于创建帮助器对象
        private SQLiteDatabase db;   //用于创建数据库对象
    private static final String name = "JZ.db"; //数据库名称
    private static final int version = 1; //数据库版本

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_h_u_i_z_o_n_g);
    Intent intent=getIntent();
    String shijian=intent.getStringExtra("NowTime");
    databaseHelper = new DataBase(this, name, null, version);
    DataBase moh=new DataBase(this,"JZ.db", null, 1);
    SQLiteDatabase db = moh.getReadableDatabase(); // 以只读的方式打开数据库
    List<BanBean> list=new ArrayList<>();
    String sql = "select * from ban;";
    Cursor cursor = db.rawQuery(sql, null);
    while (cursor.moveToNext()) {
    String id = cursor.getString(cursor.getColumnIndex("banji"));
    String pass = cursor.getString(cursor.getColumnIndex("renshu"));
    BanBean person = new BanBean(id,pass);
    list.add(person); // 添加到数组
    }
    cursor.close();

    int[] jiankang=new int[list.size()];
    int[] yichang=new int[list.size()];
    int[] weibao=new int[list.size()];
    List<HZBean> jilu=new ArrayList<>();
    sql = "select * from jilu where riqi =""+shijian+"";";
    cursor = db.rawQuery(sql, null);
    while (cursor.moveToNext()) {
    String wendu = cursor.getString(cursor.getColumnIndex("wendu"));
    String banji = cursor.getString(cursor.getColumnIndex("banji"));
    HZBean person = new HZBean(wendu,banji);
    jilu.add(person); // 添加到数组
    }
    cursor.close();
    for(int i=0;i<list.size();i++){
    jiankang[i]=0;
    yichang[i]=0;
    for(int j=0;j<jilu.size();j++){
    if(list.get(i).getBanming().equals(jilu.get(j).getBanji())){
    if(Double.parseDouble(jilu.get(j).getWendu())>=34.0&&Double.parseDouble(jilu.get(j).getWendu())<=37.0){
    jiankang[i]=jiankang[i]+1;
    }
    else if(Double.parseDouble(jilu.get(j).getWendu())<34.0||Double.parseDouble(jilu.get(j).getWendu())>37.0){
    yichang[i]=yichang[i]+1;
    }
    }
    }
    weibao[i]=Integer.parseInt(list.get(i).getRenshu())-jiankang[i]-yichang[i];
    }


    ListView listView = (ListView) this.findViewById(R.id.listView1);
    List<HashMap<String, Object>> Item = new ArrayList<>();
    for (int i = 0; i < list.size(); i++) {
    HashMap<String, Object> item = new HashMap<>();
    item.put("H_Ban", list.get(i).getBanming());
    item.put("H_Jian",jiankang[i]);
    item.put("H_Yi",yichang[i]);
    item.put("H_Wei",weibao[i]);
    Item.add(item);
    }
    SimpleAdapter adapter = new SimpleAdapter(HUIZONG.this, Item, R.layout.item1, new String[]{"H_Ban", "H_Jian", "H_Yi", "H_Wei"}, new int[]{R.id.H_Ban, R.id.H_Jian,R.id.H_Yi, R.id.H_Wei});
    listView.setAdapter(adapter);
    }

    }
    读取信息后用ListView进行显示,完成了汇总。

  • 相关阅读:
    XMPP serverejabberd-14.12本地搭建
    uva 699 The Falling Leaves(建二叉树同一时候求和)
    ORA-22828 输入样式或替换參数超过了32k限制大小
    Timus 1149. Sinus Dances 打印复杂公式
    POJ2226
    3149 爱改名的小融 2
    1169 传纸条 2008年NOIP全国联赛提高组 个人博客:attack.cf
    1019 集合论与图论
    1215 迷宫
    1020 孪生蜘蛛
  • 原文地址:https://www.cnblogs.com/ruangongwangxiansheng/p/14908117.html
Copyright © 2011-2022 走看看