如何创建自己的主题为alertDialog? [英] How can I create my own theme for alertDialog?
问题描述
我想创建一个不同的主题,所有alertDialog实例。我需要我自己的标题视图,而不是通常的黑色标题背景。所有文本应该有一个蓝色,并且alertDialog的边缘设置为圆形。
I want to create a different theme for all of alertDialog instances. I need my own title view instead of the usual black title background. All text should have a blue color, and set the edge of the alertDialog to a round shape.
是否有可能创造我们自己的主题警报对话框,使用任何风格或创建延伸的类 AlertDialog.Builder
?我需要一个共同的主题或风格alertDialog我的所有实例。我使用alertDialog在许多地方 - 一个用于singleChoice项目,其中一个ArrayAdapter
Is it possible to create our own theme for alert dialogs, using any style or creating a class which extends AlertDialog.Builder
? I need a common theme or style for my all instances of alertDialog. I am using alertDialog in many places - one for singleChoice items, one with ArrayAdapter.
我alertDialog与阵列适配器:
My alertDialog with array adapter:
String[] items = {"Edit profile","Change user","Change password","Logout"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(Loged.this,
R.layout.my_spinner_layout, items);
settingMenu.setAdapter(adapter, listener);
我alertDialog单选择题:
My alertDialog with single choice items:
alertDelete = new AlertDialog.Builder(getParent());
alertDelete.setTitle("Delete");
alertDelete.setCancelable(true);
CharSequence[] choice = {"this user","All user"};
alertDelete.setSingleChoiceItems(choice, 0,
有关我的一切alertDialog,我需要一个共同的主题,如:
For my all alertDialog, I need a common theme, like:
推荐答案
我解决我的问题通过创建扩展对话框类的,我创造了我自己的功能。例如setMessage,的setTitle,setPositiveButton,setNegativeButton等。
I solved my problem by creating a class which extends Dialog, and I created my own functions. for example setMessage,setTitle,setPositiveButton,setNegativeButton etc.
但我困惑我们如何能取代setAdapter()和setSingleChoice()。
But am confusing on how we can replace the setAdapter() and setSingleChoice().
这篇关于如何创建自己的主题为alertDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!