Alert Dialogue Title And Message Are Not Shown
Solution 1:
You have to pass theme as well in AlertBuilder.
AlertDialog.Builder myAlert = new AlertDialog.Builder(getContext(), R.style.AppCompatAlertDialogStyle);
deleteAlert.setTitle(title);
deleteAlert.setMessage(message);
deleteAlert.setPositiveButton(android.R.string.ok, clickListener);
deleteAlert.setNegativeButton(android.R.string.cancel, clickListener);
deleteAlert.show();
No need to call the create() method if you have called show(). Because internally the show() method calls create().
Note: I can clearly say the issue from my experience. I missed to pass theme.
R.style.AppCompatAlertDialogStyle
DOES NOT WORK:
AlertDialog.Builder myAlert = new AlertDialog.Builder(getContext());
WORKS SUCCESFULLY:
AlertDialog.Builder myAlert = new AlertDialog.Builder(getContext(), R.style.AppCompatAlertDialogStyle);
Solution 2:
Instead of context
, try to use ActivityName.this
.
Solution 3:
I don't know what is causing it, but for start I'm pretty sure you don't need to call builder.create()
then dialog.show()
separately.
Call directly builder.show()
and let the Alert Dialog Builder handle its creation and display. If you really need the dialog
instance, get it from the result of the builder.show()
.
About the lack of texts, maybe you are overriding some style, have you checked if the texts are simply White colored and because of that are "invisible"?
Post a Comment for "Alert Dialogue Title And Message Are Not Shown"