0

I want to add auto slider image with indicator using image link inside my android application, but the error i got is here

Cannot resolve constructor 'SlideModel(java.lang.String, java.lang.String)

Main Activity

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<com.denzcoskun.imageslider.ImageSlider
    android:id="@+id/image_slider"
    android:layout_width="wrap_content"
    android:layout_height="250dp"
    app:iss_auto_cycle="true"
    app:iss_period="1000"
    app:iss_delay="0"
    tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>

Main Activity java

package com.example.imageslider;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
import com.denzcoskun.imageslider.ImageSlider;
import com.denzcoskun.imageslider.models.SlideModel;
import java.util.ArrayList;
import java.util.List;

public class MainActivity<val> extends AppCompatActivity {
ImageSlider imageSlider;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
    WindowManager.LayoutParams.FLAG_FULLSCREEN);

    imageSlider = (ImageSlider) findViewById(R.id.image_slider);
    final List<com.denzcoskun.imageslider.models.SlideModel> remoteImg = new ArrayList<>();

    remoteImg.add(new SlideModel(R.drawable.banner_img, "The animal population decreased by 58 
    percent in 42 years."));

    }
 }

I am a beginner in Android Studio Please help me to fix this problem. I will be very Thanks for them

2 Answers2

0
  • Use version '0.0.6' of denzconkun:ImageSlideshow

    dependencies { implementation 'com.github.denzcoskun:ImageSlideshow:0.0.6' }

https://youtu.be/1AS5HcXPpqk

DavidW
  • 29,336
  • 6
  • 55
  • 86
sxchintha
  • 11
  • 3
  • It isn't really clear that this is answering the question - it seems to just be recommending a different library instead – DavidW Sep 26 '21 at 08:41
  • @DavidW It is not a different library. In the above code he has already used the denzconkun:ImageSlideshow. I also faced to the same problem when I used the new version of it. So I recommended to use the 0.0.6 version of the same library. – sxchintha Sep 27 '21 at 09:11
  • Fair point my mistake - I think a bit of explanation (maybe a link to the bug that was fixed, or even an indication of where your "dependencies" lines should go) would make this a more useful answer – DavidW Sep 27 '21 at 09:31
0

Try using

remoteImg.add(
  new SlideModel(R.drawable.banner_img, 
    "The animal population decreased by 58 percent in 42 years.", 
    ScaleTypes.FIT)
 );

instead of

remoteImg.add(
  new SlideModel(R.drawable.banner_img, 
  "The animal population decreased by 58 percent in 42 years.")
);

as the constructor have three variables

Oleg Ushakov
  • 1,200
  • 14
  • 27