I am trying to create an AlertDialog like this:
counterButton.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLong
Since your theme is related to your Activity
, you must pass it as the context
to AlertDialog.Builder
- getApplicationContext()
has no theme attached to it which is why you are getting an error.
as error said
You need to use a Theme.AppCompat theme
then you will create style extend AppTheme
!-- Base application theme. -->
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>