我无法找到解决方案!我正在尝试遵循Android 2.1及更高版本。AlertDialog与列表项和自定义主题
我尝试创建一个相当于AlertDialog一个自定义主题。
我发现在API v.11之前无法在AlertDialog上应用主题。我尝试使用ContextThemeWrapper,但找不到定制按钮的解决方案。
对于一个简单的观点,我创造我自己的对话与我自己的内容视图。我做了我想要的主题。
但是,当我想要一个AlertDialog使用自定义主题和列表项,它是比较复杂的。我找不到在列表末尾添加按钮的解决方案。因为当列表太大时,按钮在窗口外面。
我试着用: - 一个RelativeLayout的: *下面标题 *按钮标题 *的ListView下面的ListView - 一个的LinearLayout垂直
任何人有一个想法?
我添加了result needed。
也许,我的最后一个,也是非常丑陋的想法是,用builder创建一个正常的AlertDialog,用findViewById查找每个视图并应用所需的主题属性......但是我必须看看自从Android以来,ID是否是常量2.1 ...
我的布局XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bw="http://schemas.android.com/apk/res-auto/com.levelup.beautifulwidgets"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginBottom="8dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/ab_background"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/grey_1"
android:textSize="24dp" />
<FrameLayout
android:id="@+id/title_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="5dp"
android:paddingRight="10dp" />
<ListView
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title" />
<LinearLayout
android:id="@+id/buttons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@id/container"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<Button
android:id="@+id/cancel_button"
style="@style/DialogButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="-1dp"
android:layout_weight="1"
android:text="@string/cancel" />
<Button
android:id="@+id/ok_button"
style="@style/DialogButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/ok" />
</LinearLayout>
</RelativeLayout>
这应该是可以用RelativeLayout实现的,你可以发布你试过的代码吗?也许我们可以帮助你实现它。 – FoamyGuy 2012-08-08 16:06:57
我只是添加了xml文件。 – JulienDR 2012-08-09 07:40:34
我找到了一个解决方案。 我是一个垂直的LinearLayout。 所有的观点都与layout_weight 0 只是ListView控件是1 – JulienDR 2012-08-09 13:48:59