3

I am trying to use FrescoImageViewer to show images in full screen, however when I try to do that, I got this excpetion

java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
    at android.support.v7.app.AppCompatDelegateImplV9.createSubDecor(AppCompatDelegateImplV9.java:354)
    at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:323)
    at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
    at android.support.v7.app.AppCompatDialog.setContentView(AppCompatDialog.java:83)
    at android.support.v7.app.AlertController.installContent(AlertController.java:231)
    at android.support.v7.app.AlertDialog.onCreate(AlertDialog.java:278)
    at android.app.Dialog.dispatchOnCreate(Dialog.java:403)
    at android.app.Dialog.show(Dialog.java:302)
    at com.stfalcon.frescoimageviewer.ImageViewer.show(ImageViewer.java:61)
    at com.stfalcon.frescoimageviewer.ImageViewer$Builder.show(ImageViewer.java:435)
    at me.lkp111138.social_platform.activity.PostViewActivity$5.onClick(PostViewActivity.java:258)
    at android.view.View.performClick(View.java:6294)
    at android.view.View$PerformClick.run(View.java:24770)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6494)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

In fact, the theme I am using for all my activities within the app are either @style/AppTheme or @style/AppTheme.NoActionBar, and @style/AppTheme for the activity I am calling the viewer from.

And here's styles.xml

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <!-- Customize your theme here. -->
        <item name="colorPrimary">@color/colorPrimary</item>
        <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
        <item name="colorAccent">@color/colorAccent</item>
        <item name="android:windowTitleSize">40dp</item>
        <item name="windowActionBar">true</item>
    </style>

    <style name="AppTheme.NoActionBar" parent="AppTheme">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>
        <item name="android:windowTitleSize">40dp</item>
    </style>

    <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />

    <style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

</resources>

Any help will be greatly appreciated!

lkp111138
  • 193
  • 1
  • 9
  • How exactly are you instantiating the `ImageViewer.Builder`? – Mike M. Apr 18 '18 at 01:54
  • @MikeM. As instructed by README.md `new ImageViewer.Builder(getApplicationContext(), list) .setStartPosition(0) .show();` – lkp111138 Apr 18 '18 at 06:09
  • 1
    The README is a little ambiguous, but it doesn't explicitly specify `getApplicationContext()`, just `context`. That's your problem. You need to pass the `Activity` there; i.e., `PostViewActivity.this`. – Mike M. Apr 18 '18 at 06:12
  • 1
    @MikeM. That's the solution. Thanks a lot. – lkp111138 Apr 18 '18 at 09:34

0 Answers0