我正在构建一个简单的程序来添加、显示、编辑和删除。这就是发生的事情。如果我尝试使用“添加”按钮添加一些内容,我只能看到空行。如果我编辑空行并按“更新”按钮,一切正常保存和shos?为什么会这样?这是我的按钮代码:
add_save_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
///////// check the value state is null or not
/////if (valid_earring != null && valid_age != null && valid_weight != null && valid_milkproduction != null && valid_breed != null && valid_dateoffertilization != null && valid_notes != null &&
//valid_earring.length() != 0 && valid_age.length() != 0 && valid_weight.length() != 0 && valid_milkproduction.length() != 0 && valid_breed.length() != 0 && valid_dateoffertilization.length() != 0 && valid_notes.length() != 0) {
dbHandler.Add_Contact(new Contact(valid_earring,valid_age, valid_weight,valid_milkproduction,valid_breed, valid_dateoffertilization,valid_notes));
Show_Toast(Toast_msg);
Reset_Text();
//////////}
}
});
update_btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
valid_earring = add_earring.getText().toString();
valid_age = add_age.getText().toString();
valid_weight = add_weight.getText().toString();
valid_milkproduction = add_milkproduction.getText().toString();
valid_breed = add_breed.getText().toString();
valid_dateoffertilization = add_dateoffertilization.getText().toString();
valid_notes = add_notes.getText().toString();
// check the value state is null or not
//////if (valid_earring != null && valid_age != null && valid_weight != null && valid_milkproduction != null && valid_breed != null && valid_dateoffertilization != null && valid_notes != null &&
///// valid_earring.length() != 0 && valid_age.length() != 0 && valid_weight.length() != 0 && valid_milkproduction.length() != 0 && valid_breed.length() != 0 && valid_dateoffertilization.length() != 0 && valid_notes.length() != 0) {
dbHandler.Update_Contact(new Contact(USER_ID, valid_earring,valid_age, valid_weight,valid_milkproduction,valid_breed, valid_dateoffertilization,valid_notes));
dbHandler.close();
Toast_msg = "Data Update successfully";
Show_Toast(Toast_msg);
Reset_Text();
//} else {
/// Toast_msg = "Sorry Some Fields are missing.\nPlease Fill up all.";
/// Show_Toast(Toast_msg);
/////////}
}
});