In my project there is an image slider done by daimajia AndroidImageSlider . When i click on image i want to open another activity/page. I have tried and inserted an linearlayout inside the sliderlayout. But click listener in this linearlayout makes sliderlayout stuck.
<com.daimajia.slider.library.SliderLayout
android:id="@+id/advertiseSlider"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:id="@+id/linearSlider"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</com.daimajia.slider.library.SliderLayout>
Have not tested this code properly but it goes something like this:
SliderLayout mySliderLayout = (SliderLayout) findViewById(R.id.slider);
for (int i = 0; i < item.getImages().size(); i++) {
BaseSliderView baseSliderView = new BaseSliderView(context) {
@Override public View getView() {
View v = LayoutInflater.from(getContext()).inflate(R.layout.image_slider, null);
ImageView target = (ImageView) v.findViewById(R.id.daimajia_slider_image);
bindEventAndShow(v, target);
return v;
}
};
baseSliderView.image(item.getImages().get(i));
baseSliderView.setOnSliderClickListener(new BaseSliderView.OnSliderClickListener() {
@Override public void onSliderClick(BaseSliderView slider) {
Log.d("MyActivity", "index selected:" + mySliderLayout.getCurrentPosition());
}
});
mySliderLayout.addSlider(baseSliderView);
}