You need to use a Theme.AppCompat theme (or descendant) with this activity
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.
Update: Extending AppCompatActivity
would also have this problem
In this case, change the Java inheritance from ActionBarActivity
to Activity
and leave the dialog theme in the manifest as it is, a non Theme.AppCompat
value
The general rule is that if you want your code to support older versions of Android, it should have the AppCompat
theme and the java code should extend AppCompatActivity
. If you have *an activity that doesn't need this support, such as you only care about the latest versions and features of Android, you can apply any theme to it but the java code must extend plain old Activity
.
NOTE: When change from AppCompatActivity
(or a subclass, ActionBarActivity
), to Activity
, must also change the various calls with "support" to the corresponding call without "support". So, instead of getSupportFragmentManager
, call getFragmentManager
.
How to fix: You need to use a Theme.AppCompat theme (or descendant) with this activity
Your application has an AppCompat theme
<application
android:theme="@style/AppTheme">
But, 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 define 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>
</style>
Then set that on the Activity.
<activity android:name=".MainActivity"
android:theme="@style/AppFullScreenTheme" >
Note: There might be an AppCompat theme that's already full screen, but don't know immediately
You need to use a Theme.AppCompat theme (or descendant) with this activity.
Your Welcome_Activity
probably extends AppCompatActivity
so the theme should be appcompat theme.
In your styles.xml file put this:
<style name="AppTheme.FullScreen" parent="@style/Theme.AppCompat.Light">
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
Now you can use this theme:
<activity
android:name=".Welcome_Activity"
android:theme="@style/AppTheme.FullScreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
This will apply fullscreen theme for this particular activity. If you want full screen for whole application you can just replace the application theme in manifest with this theme.
How can I fix this error: You need to use a Theme.AppCompat theme (or descendant) with this activity
If you have another styles files in side another values folders like "values-v11
", "values-v14
"... Edit theme also and try to clean your app before running.
Edited:
From your activity change getApplicationContext()
to this
:
AlertDialog.Builder builder = new AlertDialog.Builder(getApplicationContext());
to
AlertDialog.Builder builder = new AlertDialog.Builder(this);
Because the dialog also should extends the Appcompat
Theme.
Android You need to use a Theme.AppCompat theme (or descendant) with the design library
try this changes:
in gradle:
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:design:25.2.0'
Also in manifest add the appcompat
theme to your Navaigation drawer `Activity
<activity android:name=".activity.FormActivity"
android:theme="@style/Theme.AppCompat">
<intent-filter>
<action android:name="info.androidhive.navigationdrawer.activity.FormActivity" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Error You need to use a Theme.AppCompat theme (or descendant) with activity
Solution is change the Java inheritance from ActionBarActivity to Activity and leave the dialog theme in the manifest as it is, a non Theme.AppCompat value
In your case issue is with your manifest file you haven't specified android:theme="@style/AppTheme.NoActionBar"
inside activities tag
Go your manifest file and replace splash activity with this:
<activity
android:name=".activities.SplashActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Inside your splash activity class do this:
public class SplashActivity extends AppCompatActivity
Related Topics
Flutter Does Not Find Android Sdk
How to Update My Adt in Eclipse
How to Hide System Navigation Bar in Tablets
Work Around Canvas.Clippath() That Is Not Supported in Android Any More
Android: How to Center Title in Toolbar
Rotating Phone Quickly 180 Degrees, Camera Preview Turns Upside Down
Android Textview:"Do Not Concatenate Text Displayed with Settext"
Play Sound on Button Click Android
Android N Requires the Ide to Be Running with Java 1.8 or Later
Android: How Do Bluetooth Uuids Work
Searchview's Oncloselistener Doesn't Work
Cannot Resolve Method Setlatesteventinfo
Android: How to Make an Activity Return Results to the Activity Which Calls It
How to Handle Outofmemoryerror
Filter Listview with Arrayadapter