【发布时间】:2013-12-10 19:02:10
【问题描述】:
我想让我的 AlertDialog TextView 颜色(自定义视图)取决于 Android 版本。 在 Android 2.x AlertDialog 有深色背景,在 Android 4.0 有浅色背景。所以文本颜色必须是白色或黑色。 如何引用自动为我制作的样式或主题?
这是我的代码:
AlertDialog.Builder alert = new AlertDialog.Builder(this);
LayoutInflater factory = LayoutInflater.from(this);
View view = factory.inflate(R.layout.remotedialog, null);
alert.setView(view);
这是我的自定义视图:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textviewremoteusername"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="???"
android:text="@string/remoteusernametitle" />
<EditText android:id="@+id/edittextremoteusername"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="textNoSuggestions"
android:maxLines="1"/>
</LinearLayout>
【问题讨论】:
标签: android styles textview android-alertdialog