问题显示自定义警报对话框
|
我无法正常显示自定义提醒对话框。为了介绍这个问题,我的应用程序可以动态地在Theme.Holo.Light和Theme.Holo.Dark之间切换。当我显示具有默认布局的警报时,警报对话框将毫无问题地继承活动的主题。当我为警报对话框定义自定义布局(包含文本视图/编辑文本)时,在将应用程序设置为Theme.Holo.Dark时,它们显示良好,但是,当将其设置为Theme.Holo.Light时,它们将显示在文本视图中为非常浅的灰色,并且edittext的边框和文本几乎是不可见的(白色背景上的白色)。我可以通过某种方式解决此问题的唯一方法是,直接在每个文本字段的自定义对话框xml布局文件的textviews中声明文本的颜色。但是,要使用此方法,我将需要为holo.light和holo.dark主题创建单独的布局。除此之外,我找不到有关如何更改edittext字段的边框颜色的任何信息,这也是一个问题。我曾尝试在AlertDialog.Builder中创建和指定主题,但是这似乎从未应用过文本样式,正如我之前说过的,我无法弄清楚如何更改edittext字段的边框颜色或使它们成为边框特别是继承自Holo.Light主题。相关代码如下,任何帮助将不胜感激。
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<TableLayout
xmlns:android=\"http://schemas.android.com/apk/res/android\"
android:layout_width=\"match_parent\"
android:layout_height=\"match_parent\">
<TableRow android:id=\"@+id/tableRow1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\">
<TextView android:text=\"First Name\" android:id=\"@+id/fname\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></TextView>
<EditText android:text=\"\" android:id=\"@+id/fname_input\" android:layout_width=\"225sp\" android:layout_height=\"wrap_content\"></EditText>
</TableRow>
<TableRow android:id=\"@+id/tableRow2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\">
<TextView android:text=\"Last Name\" android:id=\"@+id/lname\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></TextView>
<EditText android:text=\"\" android:id=\"@+id/lname_input\" android:layout_width=\"225sp\" android:layout_height=\"wrap_content\"></EditText>
</TableRow>
</TableLayout>
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
String text = getArguments().getString(\"text\");
String title = getArguments().getString(\"title\");
View layout_view = null;
int layout = getArguments().getInt(\"layout\");
if(layout != -1){
LayoutInflater inflater = (LayoutInflater) getActivity().getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE);
layout_view = inflater.inflate(layout, (ViewGroup)getActivity().findViewById(R.layout.main));
}
return new AlertDialog.Builder(getActivity()/*,AlertDialog.THEME_HOLO_DARK*/)
.setTitle(title)
.setMessage(text)
.setView(layout_view)
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}
)
.create();
}
没有找到相关结果
已邀请:
0 个回复