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?
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.
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); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With