开发者

AlertDialog with too large text and width

开发者 https://www.devze.com 2023-04-04 20:43 出处:网络
I am using Android 2.3 I have an alertdialog in my app. Here the code: final CharSequence[] items = { \"Entfernen\", \"Auswählen\",

I am using Android 2.3

I have an alertdialog in my app. Here the code:

final CharSequence[] items = { "Entfernen", "Auswählen",
                    "Editieren", "Zurücksetzen", "Abbrechen" };

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setT开发者_开发技巧itle(productName);
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {...}

I have a strange problem: The Dialog always fills the whole width of my display. And therefore the text of the selectors is very large. How can I limit this? Either textsize or width of this dialog...


You can call the following method of your alert dialog to inflate a custom xml into your alert dialog.

dialog.setContentView(R.layout.alert_dialog);

After calling this, you would need to set TextView/ImageView variables, just like how you would with activities.

For a better example, check out Android API Docs. http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog

0

精彩评论

暂无评论...
验证码 换一张
取 消