我使用过daimajia / AndroidImageSlider库。如何为不同的图像设置不同的持续时间?是否可以为图像设置不同的持续时间?例如,如果有两类图像,则类别A持续时间为15秒,类别B为5秒
false
答案 0 :(得分:1)
所以,经过大量的反复试验,我已经实现了我的目标。我必须定期在17秒和3秒后手动关闭自动循环和交换滑块。如果有更好的解决方案,请告诉我。
for (String name : url_maps.keySet()) {
//textSliderView = null;
customSliderView = null;
//textSliderView = new TextSliderView(getApplicationContext());
customSliderView = new CustomSliderView(getApplicationContext());
// initialize a SliderLayout
customSliderView
//.description(name)
.image(url_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.CenterCrop);
//.setOnSliderClickListener(this);
mDemoSlider.addSlider(customSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.DepthPage);
//mDemoSlider.setDuration(MY_DURATION);
mDemoSlider.destroyDrawingCache();
mDemoSlider.setDrawingCacheEnabled(false);
mDemoSlider.clearDisappearingChildren();
mDemoSlider.stopAutoCycle();
//mDemoSlider.startAutoCycle(MY_DURATION, MY_DURATION, true);
//mDemoSlider.addOnPageChangeListener(this);
然后2个交换功能
private void initViewPager() {
//sendRequest();
//callAsynchronousTask();
callTimer1();
}
private void callTimer1() {
// Auto start of viewpager
final Runnable Update = new Runnable() {
public void run() {
//viewPager.setCurrentItem(1, true);
//mDemoSlider.moveNextPosition(true);
mDemoSlider.setCurrentPosition(0, true);
}
};
final Timer swipeTimer = new Timer();
swipeTimer.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
swipeTimer.cancel();
callTimer2();
}
}, 3500, 17000);
}
private void callTimer2() {
final Runnable Update = new Runnable() {
public void run() {
//viewPager.setCurrentItem(0, true);
mDemoSlider.setCurrentPosition(1, true);
//mDemoSlider.moveNextPosition(true);
}
};
final Timer swipeTimer2 = new Timer();
swipeTimer2.schedule(new TimerTask() {
@Override
public void run() {
handler.post(Update);
swipeTimer2.cancel();
callTimer1();
}
}, 17000, 3500);
}