Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert dialog buttons problems in Android L

I have created a AlertDialog in my app. Before Android L AlertDialog buttons fit in dialog box, but in Android L buttons label automatically converts in title case and buttons not fit in dialog box. Please see screenshots:

Android L:
Android L AlertDialog screenshot

Android Kitkat:

Android 4.4 AlertDialog screenshot

Is anybody see this issue. Can any help me to solve this problem, although this is latest android version.

Code: (I have not used xml code to create dialog, here is java code:)

AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle(R.string.feedback_label);
        alert.setMessage(msgStrId);
        alert.setNegativeButton(R.string.close_label, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
            }
        });
        alert.setPositiveButton(R.string.rate_app, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
            }
        });
        alert.setNeutralButton(R.string.feedback_label,new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) 
            {
                // TODO Auto-generated method stub
            }
        });
        alert.setOnCancelListener(new DialogInterface.OnCancelListener() 
        {
            @Override
            public void onCancel(DialogInterface dialog) 
            {
                // TODO Auto-generated method stub
            }
        });
        AlertDialog alertDialog = alert.create();
        alertDialog.show();
like image 777
DevK Avatar asked Nov 03 '14 06:11

DevK


People also ask

How many buttons can an alert dialog display?

AlertDialog. A dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout.

How do I turn off alerts in dialog?

AlertDialog generally consists of the main title, the message, and two buttons, technically termed as a positive button and a negative button. Both positive and negative buttons can be programmed to perform various actions. By default, the negative button lets close the AlertDialog without any additional lines of code.

What is the difference between an alert and an alert dialog?

AlertDialog is a lightweight version of a Dialog. This is supposed to deal with INFORMATIVE matters only, That's the reason why complex interactions with the user are limited. Dialog on the other hand is able to do even more complex things .

What is alert dialog in Android?

Alert Dialog shows the Alert message and gives the answer in the form of yes or no. Alert Dialog displays the message to warn you and then according to your response the next step is processed. Android Alert Dialog is built with the use of three fields: Title, Message area, Action Button.


2 Answers

I know, I am too late. But I share my suggestion here. Maybe it will be helpful.

  AlertDialog alertDialog  = alert.create();
    alertDialog .show();
    alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).setAllCaps(false);
    alertDialog.getButton(DialogInterface.BUTTON_POSITIVE).setAllCaps(false);
    alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setAllCaps(false);
 alertDialog.show();
like image 152
Kush Avatar answered Sep 22 '22 08:09

Kush


AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.MyAlertDialogStyle);

styles.xml

<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog">
    <item name="android:textAllCaps">false</item>
</style>
like image 27
Ahamadullah Saikat Avatar answered Sep 21 '22 08:09

Ahamadullah Saikat