Je veux la boîte de dialogue d'alerte en cliquant sur le bouton positif pour afficher le toast, mais à la place, il montre un erorr!Faire un toast à partir du dialogue d'alerte positif Bouton
le code
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();
}
});
l'erreur msg
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)