猿问

android新手上路,实在想不通了,帮忙看看

 把数据库的数据放入一个传感器c1里面,然后再把c1存入list

现在我想给airT_tv3的设置文本内容为数据库的第一行数据的airT的值,我要怎么写参数?

 public void run() {
    list=new ArrayList<ChuanganqiInfo>();
    Cursor currsor=db.query("nongye",null,null,null,null,null,null);
    if(currsor.moveToFirst()){
        do {
            c1=new ChuanganqiInfo();
            c1.setAirT(currsor.getInt(1));
            c1.setAirH(currsor.getInt(2));
            c1.setLight(currsor.getInt(3));
            c1.setSoilT(currsor.getInt(4));
            c1.setSoilH(currsor.getInt(5));
            c1.setCo2(currsor.getInt(6));
            list.add(c1);
        }while (currsor.moveToNext());
    }
    //ChuanganqiInfo c1=new ChuanganqiInfo();
    currsor.close();
    airT_tv3.setText(list.get(j).toString());//设置文本在这里
    j++;
    if (j==currsor.getCount()){
        j=0;
    }
    Toast.makeText(mContext,"刷新",Toast.LENGTH_SHORT).show();
    handler.postDelayed(this,5000);
}

 

慕前端6305810
浏览 1222回答 1
1回答

qq_匡璐_0

c1=new ChuanganqiInfo();不应该放在do while循环里其次你的代码不全 变量 j 是干啥的看不懂
随时随地看视频慕课网APP

相关分类

Android
Java
我要回答