我有这个代码:
public class Example
{
String sp,st;
SQLiteDatabase database, database2;
void func()
{
new AlertDialog.Builder(view.getContext())
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Confirm")
.setMessage("Are you sure?")
.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which) {
String st = editTextSt.getText().toString();
String sp = editTextSp.getText().toString();
database2 = new SQLiteDbHelper(this);
database = database2.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(SQLiteDbHelper.COLUMN_NAME_SP, sp);
values.put(SQLiteDbHelper.COLUMN_NAME_ST, st);
long insertId = database.insert(SQLiteDbHelper.TABLE_NAME, null, values);
//I would like to call it here
}})
.setNegativeButton("No", null)
.show();
}
我想在上面的 AlertDialog 中调用这个 AlertDialog:
new AlertDialog.Builder(this)
.setMessage("Saved!")
.setNeutralButton("OK", null)
.show();
我该怎么做?
如果我只是把它放在我想要的地方,我会收到“构造函数 AlertDialog.Builder(new DialogInterface.OnClickListener(){}) 未定义”的错误。