JAVA日报
app开发(SecondActivity)
package com.example.jizhang;
import android.os.Bundle;
import android.widget.EditText;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import dao.userdao;
public class SecondActivity extends AppCompatActivity{
private EditText editTextt1;
private EditText editTextt2;
private EditText editTextt3;
private EditText editTextt4;
private EditText editTextt5;
private EditText editTextt6;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
InitData();
}
private void InitData(){
editTextt1 = (EditText) findViewById(R.id.edt_eat2);
editTextt2 = (EditText) findViewById(R.id.edt_play2);
editTextt3 = (EditText) findViewById(R.id.edt_clothes2);
editTextt4 = (EditText) findViewById(R.id.edt_live2);
editTextt5 = (EditText) findViewById(R.id.edt_usual2);
editTextt6 = (EditText) findViewById(R.id.edt_total);
userdao userDao=userdao.getInstance(getApplicationContext());
userDao.Initdata();
// for(user u:userList){
// eat=eat+Double.valueOf(u.getEat());
// play=play+Double.valueOf(u.getPlay());
// clothes=clothes+Double.valueOf(u.getClothes());
// live=live+Double.valueOf(u.getLive());
// usual=usual+Double.valueOf(u.getUsual());
// }
// userdao userDao = userdao.getInstance(getApplicationContext());
// SQLiteDatabase db=userDao.getDb().getWritableDatabase();
// Cursor cursor=db.query("tex",new String[]{"date","eat","play","clothes","live","usual"},null,null,null,null,null);
// while(cursor.moveToNext()) {
// eat = eat + Double.valueOf(cursor.getString(1));
// play = play + Double.valueOf(cursor.getString(2));
// clothes = clothes + Double.valueOf(cursor.getString(3));
// live = live + Double.valueOf(cursor.getString(4));
// usual = usual + Double.valueOf(cursor.getString(5));
// }
// total=eat+play+clothes+live+usual;
editTextt1.setText(""+userDao.eat);
editTextt2.setText(""+userDao.play);
editTextt3.setText(""+userDao.clothes);
editTextt4.setText(""+userDao.live);
editTextt5.setText(""+userDao.usual);
editTextt6.setText(""+userDao.total);
userDao.clear();
}
}