CLD*_*Dev 4 android dialog android-alertdialog
我创建了一个继承自'Theme.Holo.Light.Dialog'的自定义主题.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="cust_dialog" parent="@android:style/Theme.Holo.Light.Dialog">
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
我的代码:
private AlertDialog testDialog;
AlertDialog.Builder testBuilder;
LayoutInflater inflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.test_dialog,
(ViewGroup) findViewById(R.id.test_root));
testBuilder = new AlertDialog.Builder(this, R.style.cust_dialog);
testBuilder.setView(layout);
testBuilder.setTitle("Support");
testDialog = testBuilder.create();
testDialog.show();
Run Code Online (Sandbox Code Playgroud)
这会导致我的对话框在对话框中.我该如何解决?
谢谢.
编辑::::
这是我的test_dialog.xml布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/test_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/test1"
android:layout_width="300dp"
android:layout_height="75dp"
android:text="@string/test"
android:gravity="center" />
<Button
android:id="@+id/test2"
android:layout_width="300dp"
android:layout_height="75dp"
android:text="@string/test"
android:layout_below="@id/test1"
android:gravity="center" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
试试这个.
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.MyTheme );
AlertDialog.Builder builder= new AlertDialog.Builder( ctw );
LayoutInflater inflater = (LayoutInflater) ctw.getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.customdialogue,
(ViewGroup) findViewById(R.id.layout_root));
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7663 次 |
| 最近记录: |