-2
我想點擊正面按鈕顯示烤麪包時的警告對話框,但相反,它顯示一個erorr!從警報對話框中烤麪包正面按鈕
代碼
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_dialog_alert)
.setTitle("Create new ?")
.setMessage(" Do you want to create new msg ?!")
.setPositiveButton("Yes ? ", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(this," Ready to Create New Msg",Toast.LENGTH_LONG).show();
}
});
錯誤味精
Error:(38, 30) error: no suitable method found for makeText(<anonymous
OnClickListener>,String,int)
method Toast.makeText(Context,CharSequence,int) is not applicable
(argument mismatch; <anonymous OnClickListener> cannot be converted to
Context)
method Toast.makeText(Context,int,int) is not applicable
(argument mismatch; <anonymous OnClickListener> cannot be converted to
Context)