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.
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
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>
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.
Related Topics
How to Set Button Click Effect in Android
How to Make My App Work in All Devices
How to Remove Focus from Edittext When User Is Done Editing
How to Quit Android Application Programmatically
Getting Simple Json Object Response Using Retrofit Library
Making Voice Calls from Android Phone Connected to Linux
Convert File: Uri to File in Android
Link Should Be Open in Same Web View in Android
Remove Items from Listview With a Custom Adapter
I Get Fragment Not Attached to a Context. What Context Need to Use
App Restarts Rather Than Resumes
How to Prevent User Go Back to Protected Page After Logout
Ship an Application With a Database
Android Shared Preferences For Creating One Time Activity (Example)
How Listview'S Recycling Mechanism Works
How to Get Screen Dimensions as Pixels in Android
How to Handle Notification When App in Background in Firebase