Android 对话框主题崩溃应用程序
我想用一些文本信息创建一个窗口。单击按钮后,将开始打开一个新类Android 对话框主题崩溃应用程序,android,Android,我想用一些文本信息创建一个窗口。单击按钮后,将开始打开一个新类 android:theme="@android:style/Theme.Dialog" 当我在AndroidManifest.xml中添加它时,我的应用程序在单击按钮后崩溃 打开的类的.xml文件: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/and
android:theme="@android:style/Theme.Dialog"
当我在AndroidManifest.xml中添加它时,我的应用程序在单击按钮后崩溃
打开的类的.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip">
<TextView
android:id="@+id/id_infotext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/info_text"/>
</ScrollView>
Theme.Dialog仅设计用于对话框。如果要将此主题应用于对话框,可以轻松为对话框创建单独的主题:
Theme.Dialog仅适用于应用程序中显示的对话框,而不适用于整个应用程序。试试这个: 在AndroidManifest.xml中,更新此文件:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
因此,您使用意图启动新活动,在清单中为新活动设置主题,您使用的主题用于对话框。我认为你做不到。你知道如何显示对话框吗?那是你的意图吗?嗯,我在看一本书。尝试了别的东西;android:theme=@style/theme.AppCompat.Light.Dialog,它的工作原理与预期的一样。此时会出现一个对话框窗口。所以事实上这很好。但是为什么确切的主题不起作用呢?对话主题的意义是什么?为什么不直接使用Theme.Dialog?你是对的。我总是像上面的例子那样做,如果我希望在将来添加进一步的定制。
AlertDialog alertDialog = new AlertDialog.Builder(this, R.style.DialogTheme));
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<style name="mydialogstyle" parent="android:style/Theme.Dialog">
<item name="android:windowBackground">@null</item>
<item name="android:windowNoTitle">true</item>
</style>
setStyle(R.style.mydialogstyle, 0);