我有一个类,其中包含:
@Override
public void onClick(View createView) {
switch (createView.getId()) {
case R.id.save_button:
Appointments add = new Appointments();
add.addAppointment(TITLE);
add.addAppointment(TIME);
break;
}
}
我希望能够调用另一个类中的 addAppointment 方法:
public void addAppointment(String string) {
// Insert a new record into the Appointment data source.
// You would do something similar for delete and update.
SQLiteDatabase db = events.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(TITLE, string);
values.put(TIME, string);
db.insertOrThrow(TABLE_NAME, null, values);
}
我已经尝试过这种方式,但是当我单击 onclick 时,程序崩溃了