I updated my phone to Android 6.0 and I have these 2 problems with dialogs:
1)The title is shown but the messages isn't for alert dialog(SOLVED):
new AlertDialog.Builder(context).setTitle("Title").setMessage("Message");
2)Also custom dialog fragment's title is not shown(NOT SOLVED):
getDialog().setTitle("Title");
There was not such a problem in lollipop or in older versions, the problem appeared only after updating my phone to marshmallow.
How to solve the problem?
Use constructor with theme for Lollipop and newer android versions:
Dark theme
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(context, android.R.style.Theme_Material_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(context);
}
And for Light theme
AlertDialog.Builder builder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder = new AlertDialog.Builder(context, android.R.style.Theme_Material_Light_Dialog_Alert);
} else {
builder = new AlertDialog.Builder(context);
}