Reputation: 970
I want to add and Slider to my Android App, but I get this error:
Error: cannot find symbol method addOnPageChangeListener(MainActivity)
These are my dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.daimajia.slider:library:1.0.9@aar'
compile 'com.squareup.picasso:picasso:2.3.2'
}
And this is my code:
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.daimajia.slider.library.Indicators.PagerIndicator;
import com.daimajia.slider.library.SliderLayout;
import com.daimajia.slider.library.Tricks.ViewPagerEx;
import java.util.HashMap;
public class MainActivity extends AppCompatActivity implements ViewPagerEx.OnPageChangeListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
HashMap<String, Integer> file_maps = new HashMap<>();
file_maps.put("Image1", R.drawable.image_1);
file_maps.put("Image2", R.drawable.image_2);
file_maps.put("Image3", R.drawable.image_3);
SliderLayout imageSlider = (SliderLayout) findViewById(R.id.slider);
for (String name : file_maps.keySet()) {
SliderTextView SliderTextView = new SliderTextView(this);
SliderTextView.description(name).image(file_maps.get(name));
imageSlider.addSlider(SliderTextView);
}
imageSlider.setCustomIndicator((PagerIndicator) findViewById(R.id.custom_indicator));
imageSlider.setPresetTransformer(SliderLayout.Transformer.Tablet);
// THIS IS THE PROBLEM
imageSlider.addOnPageChangeListener(this);
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {}
@Override
public void onPageSelected(int position) {}
@Override
public void onPageScrollStateChanged(int state) {}
}
Do somebody know, what could be wrong and how to fix it?
Upvotes: 0
Views: 1460
Reputation: 363745
You are using the 1.0.9 of the AndroidImageSlider library.
compile 'com.daimajia.slider:library:1.0.9@aar'
This version haven't this method as you can check here:
You should use the last version:
compile 'com.daimajia.slider:library:1.1.5@aar'
Upvotes: 1