我是黑莓开发的新手。我正在尝试创建一个应用程序,我必须保存名称和三个复选框结果(即是否已检查框)。我创建了一个屏幕。但我无法将数据保存在数据库中,我想使用SQLite。
请帮助我,告诉我如何继续,我有一个困惑,我将编写数据库的编码,即在主屏幕类或我必须创建另一个单独的类。
这是主屏幕的编码。
package medicine;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.component.EditField;
import net.rim.device.api.ui.component.SeparatorField;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.CheckboxField;
import net.rim.device.api.ui.component.ButtonField;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
public class EnterSuccessScreen extends MainScreen implements FieldChangeListener{
EditField nameField;
CheckboxField medicineCheckbox1;
CheckboxField medicineCheckbox2;
CheckboxField medicineCheckbox3;
ButtonField submitButton;
public EnterSuccessScreen(){
add(new LabelField("Please enter your details:"));
add(new SeparatorField());
nameField = new EditField("Medicine Name:", "");
add(nameField);
add(new SeparatorField());
add(new SeparatorField());
add(new LabelField("Time To Take the Medicine:"));
medicineCheckbox1 = new CheckboxField(" 9 a.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox1);
medicineCheckbox2 = new CheckboxField(" 12 p.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox2);
medicineCheckbox3 = new CheckboxField(" 3 p.m.", false,Field.FIELD_LEFT);
add(medicineCheckbox3);
add(new SeparatorField());
submitButton = new ButtonField("Submit", ButtonField.CONSUME_CLICK);
add(submitButton);
submitButton.setChangeListener(this);
}
public void fieldChanged(Field field, int context){
if (field == submitButton) {
submit();
}
else{}
}
private void submit(){
SubmitSuccessScreen submitSuccessScreen = new SubmitSuccessScreen();
UiApplication.getUiApplication().pushScreen(submitSuccessScreen);
}
}
答案 0 :(得分:0)
Blackberry为您在黑莓示例演示中检查SqliteDemo的问题提供了一些示例演示。