不同图像的不同持续时间
Different Duration for Different Images
我用过daimajia/AndroidImageSlider库。如何为不同的图像设置不同的持续时间??是否可以为图像设置不同的持续时间??例如,如果有两个类别的图像,类别 A 的持续时间将为 15 秒,类别 B 将为 5 秒
for (String name : url_maps.keySet()) {
customSliderView = null;
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.startAutoCycle(MY_DURATION, MY_DURATION, true);
所以,经过大量的尝试和错误,我已经实现了我想要做的事情。我不得不在 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);
}
我用过daimajia/AndroidImageSlider库。如何为不同的图像设置不同的持续时间??是否可以为图像设置不同的持续时间??例如,如果有两个类别的图像,类别 A 的持续时间将为 15 秒,类别 B 将为 5 秒
for (String name : url_maps.keySet()) {
customSliderView = null;
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.startAutoCycle(MY_DURATION, MY_DURATION, true);
所以,经过大量的尝试和错误,我已经实现了我想要做的事情。我不得不在 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);
}