我正在尝试添加一个对话框,当用户选择将删除指定行的删除按钮时,该对话框将弹出。但是我似乎无法获得程序编译的适当语法。错误发生在这一行;
MODULEDATABASE.deleteRow(rowId);
Intent intent = new Intent(this, MyCourses.class);
任何建议将不胜感激。
public class ViewCourse extends Activity implements OnClickListener{
Cursor cursor;
database MODULEDATABASE;
String rowId;
Button deleteModule;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_course);
Intent intent = getIntent();
rowId = intent.getStringExtra(MyCourses.TEST);
MODULEDATABASE = new database(ViewCourse.this);
MODULEDATABASE.openToRead(ViewCourse.this);
cursor = MODULEDATABASE.getRow(rowId);
TextView text_modulecode = (TextView)findViewById(R.id.viewModuleCode);
TextView text_modulename = (TextView)findViewById(R.id.viewModuleName);
text_modulecode.setText(cursor.getString(cursor.getColumnIndex(database.KEY_MODULECODE)));
text_modulename.setText(cursor.getString(cursor.getColumnIndex(database.KEY_MODULENAME)));
deleteModule = (Button)findViewById(R.id.deleteButton);
deleteModule.setOnClickListener(this);
}
public void onClick (View deleteModule)
{
Dialog(rowId);
}
public void Dialog (String rowId) {
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.confirmDelete)
.setPositiveButton(R.string.confirmDelete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
MODULEDATABASE = new database(ViewCourse.this);
MODULEDATABASE.deleteRow(rowId);
Intent intent = new Intent(this, MyCourses.class);
startActivity(intent);
}
})
.setNegativeButton(R.string.confirmDelete, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
}
});
}
}