如果单击接受或取消,我只需要显示一个祝酒词,但无法理解为什么错误如何解决?错误出现在吐司上,getapplicationcontext()
我了解 android 上的对话框和吐司
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.util.Log;
import android.widget.Toast;
public class confirmacion extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
AlertDialog.Builder builder= new AlertDialog.Builder(getActivity());
builder.setMessage("Confirmar?").setTitle("confirmacion")
.setPositiveButton("aceptar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.i("dialogos","aceptado");
dialog.cancel();
Toast.makeText(getApplicationContext(), "Eliminacion fallida.", Toast.LENGTH_LONG).show();
}
}).setNegativeButton("cancelar", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.i("dialogos","cancelada");
dialog.cancel();
}
});
return builder.create();
}
}