0
View imageOverlayView = 
LayoutInflater.from(getApplicationContext()).
inflate(R.layout.layout_image_overlay, null);

new ImageViewer.Builder(getApplicationContext(), imageURLs)
               .setStartPosition(0)
               .hideStatusBar(false)
               .setOverlayView(imageOverlayView)
               .show();

I'm using this ImageView builder to load images in fullscreen view, but I get the above mentioned error while compiling.And the activity which I'm using extends from AppCompatActivity. Also I tried the activity extending from Activity too, its not working.

Thank you very much for your time and assistance in this matter.

ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
  • Need more information. Show the manifest of the activity, how is it set up? this code fragment tells nothing. where is it called? where is it placed? is it in an onCreate? who calls it and when? – Grisgram Sep 21 '17 at 05:09
  • Change `getApplicationContext` to `this` or `YourActivity.this`. – Satan Pandeya Sep 21 '17 at 05:56

3 Answers3

1

The error:

You need to use a Theme.AppCompat theme (or descendant) with this activity

means that you need to use a style for the activity which is derived from AppCompat theme. It is usually in res/values/styles.xml. If you don't have create it to something like this:

<resources>

  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
  </style>

</resources>

Then, use it for your activity by adding it to AndroidManifest.xml with android:theme="@style/AppTheme" (please read the comment):

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.sample.testcode">

  <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN"/>

        <category android:name="android.intent.category.LAUNCHER"/>
      </intent-filter>
    </activity>

    <!-- Or you can use specific theme for the activity -->
    <activity
        android:name=".anotherActivity"
        android:label="@string/app_name" >
        android:theme="@style/AppTheme" >
    </activity>

  </application>

</manifest>
ישו אוהב אותך
  • 28,609
  • 11
  • 78
  • 96
0

.hideStatusBar(false)

is creating your issue.

You have to make sure that the AppTheme has a defined Status and Toolbar and the Activity uses the Theme.

By default Android Studio generates the base theme.

Niraj Sanghani
  • 1,493
  • 15
  • 23
0

You used AppCompat as the theme in the code section (that hideStatusBar), but you used another theme in the manifest or style.xml. Not consistent as you use different themes in two places So it says you need to use it.

Umut ADALI
  • 1,146
  • 1
  • 14
  • 31