本文翻译自:You need to use a Theme.AppCompat theme (or descendant) with this activity
Android Studio 0.4.5 Android Studio 0.4.5
Documentation for Creating Custom Dialog Android Boxes: http://developer.android.com/guide/topics/ui/dialogs.html used to create a custom dialog box Android documentation: HTTP : //developer.android.com/guide/ topics / ui / dialogs.html
If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. If you need a custom dialog box, you can be "active" As dialog box is displayed, instead of using the Dialog API. The Create Activity and the SET AN Simply the ITS at The Theme to Theme.Holo.Dialog in <activity>
the manifest Element: just create a theme and activities set <activity>
Theme.Holo.Dialog to the list of elements:
<activity android:theme="@android:style/Theme.Holo.Dialog" >
However, when I tried this I get the following exception: However, when I try this, the following exception:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity
I am supporting the following, and I can not using something greater than 10 for the min: I support the following, and I can not use a value greater than 10:
minSdkVersion 10
targetSdkVersion 19
In my styles I have the following: My style is as follows:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
And in my manifest I have this for the activity: In the list, I have this event:
<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. Like this is what I want to create dialog boxes do, because I have completed the layout.
Can anyone tell me how I can get around this problem? Can anyone tell me how to solve this problem?
#1st Floor
#2nd Floor
IS 10. The sdk min ActionBar
IS Available from Level 11. The API 10 So for the using BE Would you AppCompat
from The Library Support for Which you need to use Theme.AppCompat
or the descendant of The Same. minimum sdk is ActionBar
level 11 is provided ActionBar
. So, for 10, you will use to support the library AppCompat
, you need to use the library Theme.AppCompat
or its progeny.
Use Use
android:theme="@style/Theme.AppCompat" >
Or if you dont want action bar at the top or if you do not want the action bar at the top
android:theme="@style/Theme.AppCompat.NoActionBar">
More info @ More Information @
http://developer.android.com/guide/topics/ui/actionbar.html http://developer.android.com/guide/topics/ui/actionbar.html
Edit: Edit:
I might have misread op post. I may have misread the op post.
Seems op wants a Dialog with a Activity Theme. Seems to be a theme op wants a dialog with. AS already Suggested by Bobbake4 SO Extend Activity
INSTEAD of ActionBarActivity
. Therefore, as Bobbake4 as recommended, extension Activity
instead ActionBarActivity
.
Also have a look @ Dialog Attributes in the link below can also view the properties in the dialog box @ the link below
http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/frameworks/base/core/res/res/values/themes.xml/ http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.4_r1/frameworks/base/core/res/res/values/themes.xml/
#3rd floor
The this reason you are the HAVING at The problem IS at The Activity Because you are Trying to the Apply Theme to IS at The Dialog Extending ActionBarActivity
Which The requires at The AppCompat
Theme Applied to BE. The reason you are experiencing this problem is that you try to box theme to the activities being extension ActionBarActivity
, which need to be applied AppCompat
theme.
Update : Extending AppCompatActivity
Would Also have have the this problem update : extension AppCompatActivity
will have this problem
The this Case an In, Change at The Inheritance from Java ActionBarActivity
to Activity
and the Leave at The Dialog Theme in the manifest at The AS IT IS, A non Theme.AppCompat
value in this case, set to inherit from Java ActionBarActivity
change Activity
, and the dialog is left as the theme in the list ( non- Theme.AppCompat
value)
At The General rule IS that IF you want your code to Support older versions of Android, IT Should have have at The AppCompat
Theme and at The the Java code Should Extend AppCompatActivity
. The general rule is, if you want the code to support older versions of Android, it should have a AppCompat
theme, Java code should be expanded AppCompatActivity
. You have have AN Activity * IF that does not need the this Support, SUCH AS you only the About Care at The Latest Features and versions of Android, you CAN IT But the Apply to the any Theme at The Plain Old Extend the MUST the Java code Activity
. If you do not need this support activities such that you only care about the latest version of Android and function, then it can be applied to any topic, but must extend the Java code plain old Activity
.
NOTE: Change from the When AppCompatActivity
(or subclass A, ActionBarActivity
), to Activity
, the MUST Also at The Change Various Calls with "Support" in the Corresponding at The Call to the without "Support." Note: From AppCompatActivity
(or sub-category ActionBarActivity
change) is Activity
, must also be with the " support "of the various calls to change not " call the appropriate support "of. SO, INSTEAD of getSupportFragmentManager
, Call getFragmentManager
. The call getFragmentManager
in place getSupportFragmentManager
.
#4th floor
You need to do is to android:theme="@style/Theme.AppCompat.Light"
add to AndroidManifest.xml
the application file tab.
#5th Floor
Because the this to have have Came by You you want to the Apply Material Design in style in your Theme Previous versions to 21. The sdk ActionBarActivity
The requires AppTheme
SO IF you want to Prevent Also the About your AppTheme Customization your own, you only have have to Change in your styles.xml (Previous to sdk 21) so this way, can inherit for an App Compat theme. you have come to this point, because you want to in a previous version of the SDK application materials design in your theme style, with 21 ActionBarActivity
needed AppTheme
so, if you want to stop AppTheme your own custom, only you have to change your styles.xml (versions prior to 21 sdk), and therefore can be inherited App Compat theme.
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
for this: To this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
#6th floor
go to your styles and put the parent to your style, the parents
parent="Theme.AppCompat"
instead of instead of
parent="@android:style/Theme.Holo.Light"