你需要使用一个Theme.AppCompat主题(或后代)与本次活动 [英] You need to use a Theme.AppCompat theme (or descendant) with this activity
问题描述
Android的工作室0.4.5
Android Studio 0.4.5
Android的文档创建自定义对话框:<一href="http://developer.android.com/guide/topics/ui/dialogs.html">http://developer.android.com/guide/topics/ui/dialogs.html
Android documentation for creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html
如果你想有一个自定义对话框,您可以改为显示活动的对话,而不是使用对话框的API。只需创建一个活动,并设置其主题Theme.Holo.Dialog在
在&LT;活性GT;
manifest元素:
If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in
the <activity>
manifest element:
<activity android:theme="@android:style/Theme.Holo.Dialog" >
然而,当我尝试这样做,我得到以下异常:
However, when I tried this I get the following exception:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
我支持下,我不能使用的东西大于10的分钟:
I am supporting the following, and I can't using something greater than 10 for the min:
minSdkVersion 10
targetSdkVersion 19
在我的风格,我有以下:
In my styles I have the following:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
和我的表现我有这个的活动:
And in my manifest I have this for the activity:
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:theme="@android:style/Theme.Holo.Light.Dialog"
android:name="com.ssd.register.Dialog_update"
android:label="@string/title_activity_dialog_update" >
</activity>
创建对话框,这样是我在跳做的,因为我已经完成了布局。
Creating the dialog box like this was something I was hopping to do, as I have already completed the layout.
谁能告诉我怎样才能解决这个问题得到什么呢?
Can anyone tell me how I can get around this problem?
推荐答案
您有这个问题的原因是因为你尝试应用对话的主题活动是扩大 ActionBarActivity
这就要求 AppCompat
主题应用。
The reason you are having this problem is because the activity you are trying to apply the dialog theme to is extending ActionBarActivity
which requires the AppCompat
theme to be applied.
更改从 ActionBarActivity
在Java继承活动
并保持对话主题,在清单中,因为它是。
Change the Java inheritance from ActionBarActivity
to Activity
and leave the dialog theme in the manifest as it is.
这篇关于你需要使用一个Theme.AppCompat主题(或后代)与本次活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!