• Register
0 votes

Problem :

I wanted to create a custom dialog by displaying the Activity as the dialog instead of using a Dialog APIs. By creating an activity and seting its theme to the Theme.Holo.Dialog in my <activity> manifest element:

<activity android:theme="@android:style/Theme.Holo.Dialog" >

But  when I tried it I get a below exception:

“java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity”

I want to support the following, and I am unable to use something greater than 10 for the min:

minSdkVersion 10
targetSdkVersion 19

In my styles I have the below code :

<!-- Base application theme. →
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

And in my manifest I have below code for the activity: 





        android:theme="@style/AppTheme" >




            android:label="@string/title_activity_dialog_update" >


Creating a dialog box like this was something I wanted to do, because I have already completed my layout.

Can somebody tell me how I can resolve this problem?

7 5 2
3,870 points

Please log in or register to answer this question.

2 Answers

0 votes

Solution :

The reason behind your problem is as a activity you are trying to apply a dialog theme to is extending ActionBarActivity which always requires a AppCompat theme to be applied.

Just extending AppCompatActivity would also have above problem

In your case, you need to change the Java inheritance from ActionBarActivity to Activity and leave a dialog theme in a manifest as it is, the non Theme.AppCompat value.

This will solve your issue.

9 7 4
38,600 points
0 votes


The base you are having this problem is cause the activity you are attempting to apply the dialog theme to is extending ActionBarActivity which needs the AppCompat theme to be applied.


Extending AppCompatActivity would even have this issue

In this instance, alter the Java inheritance from ActionBarActivity to Activity and omit the dialog theme in the manifest as it is, a non Theme.AppCompat value

The general rule is that in case you want your code to backing older versions of Android, it must have the AppCompat theme and the java code must extend AppCompatActivity. In case you have *an activity that doesn't require this support, such as you just care about the latest versions and features of Android, you can utilize any theme to it however the java code should extend plain old Activity.


At the time alter from AppCompatActivity (or a subclass, ActionBarActivity), to Activity, should also alter the several calls with "support" to the similar call without "support". Hence, instead of getSupportFragmentManager, call getFragmentManager.

All you require to do is include android:theme="@style/Theme.AppCompat.Light" to your application tag in the AndroidManifest.xml file.

I had the error explained at the top of the post and occured after I included an alert dialog. I have all the pertinent style information in the manifest. My problem was solved by altering a context reference in the alert builder - I altered:

new android.support.v7.app.AlertDialog.Builder(getApplicationContext())


new android.support.v7.app.AlertDialog.Builder(this)

min sdk is 10. ActionBar is available from api level 11. So for 10 you would be employing AppCompat from the support library for which you require to employ Theme.AppCompat or descendant of the same.


android:theme="@style/Theme.AppCompat" >

Or in case you dont want action bar at the top


Your application has an AppCompat theme


However, you overwrote the Activity (which extends AppCompatActivity) with a theme that isn't descendant of an AppCompat theme

<activity android:name=".MainActivity"
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >

You could identify your own fullscreen theme like so (notice AppCompat in the parent=)

<style name="AppFullScreenTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>

Then fixed that on the Activity.

<activity android:name=".MainActivity"
    android:theme="@style/AppFullScreenTheme" >


10 6 4
31,120 points

Related questions

0 votes
1 answer 32 views
Problem: I have the latest version of android studio (3.0) along with the latest build tools (27) and also have the similar API level. But my layout does not get rendered in my design tab and because of this it is causing the lot of trouble especially while ... workable fix for the above problem. I have already spent more than three days on this issue. Is there any work around for this problem?
asked Jul 28, 2020 Raphael Pacheco 4.9k points
0 votes
2 answers 822 views
Problem : I want to upload the finished android app to a android market but I am getting below error: &ldquo;You need to use a different package name because "com.example" is restricted.&rdquo;
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 10 views
Problem: I am new to Android. I have recently encountered the below error in my Android. Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed ... have also chosen the Google Apis build target as well. Now can somebody here be available to guide me in my Android related error?
asked Aug 31, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 139 views
Problem : In my current application I want to get the MS-Word and PDF files through the Storage Access Framework which works well on some of the devices I have worked upon however on the Samsung note 4 API 6 I am facing following error : All apps ... "application/pdf,application/msword"); Intent i = Intent.createChooser(intent, "File"); getActivity().startActivityForResult(i, FILE_REQ_CODE); } });
asked Dec 6, 2019 alecxe 7.5k points
0 votes
1 answer 34 views
Problem: Hello Kodlogs, I tried pushing my app and I got an error message of this nature; you must use bundler 2 or greater with this lockfile. What can I do to correct this?
asked Nov 2, 2020 Festus James 360 points
0 votes
2 answers 29 views
Problem: When do you need to use a fully qualified URL in a hyperlink?
asked Jul 21, 2020 sstones 830 points
0 votes
1 answer 10 views
1 vote
1 answer 16 views
Problem: I want to know : How to pass data from one activity to another in android example . I have basic knowledge in android programming. I have one scenario where just after logging in through my login page then there will be the sign-out button on each of the ... my signed in user to the sign-out. Can someone guide me on how can I keep my session id available to all of the activities?
asked Jul 1, 2020 Raphael Pacheco 4.9k points