Android AlertDialog多选项目与自定义项目 [英] Android AlertDialog Multi Choice Items with customised items

查看:193
本文介绍了Android AlertDialog多选项目与自定义项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用setMultiChoiceItems(...)设置多选项目时,没有人知道如何在AlertDialog中自定义项目.我想更改项目的文本大小.

Does anyone know how to customize items in AlertDialog when multi choice items are set with setMultiChoiceItems(...). I would like to change the text size for the items.

谢谢

推荐答案

当然,您可以使用Dialog.setContentView()将对话框的内容设置为任意布局.

Sure, you can use Dialog.setContentView() to set the content of a dialog to be an arbitrary layout.

Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.yourLayoutId);
dialog.show();

制作一个包含所需组件的布局文件,然后在对话框中调用setContentView,并传递布局文件的名称.

Make yourself a layout file with a components that you want in it and call setContentView on your dialog, passing the name of your layout file.

如果您在AlertDialog上陷入僵局,则可以使用builder.setView()做类似的事情

If you are deadset on AlertDialog you can do something similar with builder.setView()

LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.yourLayoutId, (ViewGroup) findViewById(R.id.yourLayoutRoot));
AlertDialog.Builder builder = new AlertDialog.Builder(this)
.setView(layout);
AlertDialog alertDialog = builder.create();
alertDialog.show();

这篇关于Android AlertDialog多选项目与自定义项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆