我试图创建一个自定义的多选警告对话框,允许用户在一次点击中选择/取消选择所有项目。为此,我使用了一个带有额外复选框的自定义标题。
一切都运行得很好,除了我不知道如何使我的自定义标题看起来像默认的警告对话框标题(使用相同的样式)。
这是我想要实现的效果(示例使用对话框文档 中的主题。那只是一个示例,我真正想要的是应用程序主题):
我为使用的自定义标题创建了一个自定义视图,但我不知道如何获取默认样式标题栏的属性,因此我获得:
(标题下没有蓝色条,标题颜色错误)
以下是我的自定义标题布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/title"
style="?android:attr/textAppearanceLarge"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Dialog title" />
<TextView
android:id="@+id/all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="All" />
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
我觉得我需要定义标题属性和布局的背景...但我已经花了好几个小时在网上搜索如何获取默认标题视图的属性。
有什么想法吗?