gpt4 book ai didi

android - 不同图像的不同持续时间

转载 作者:太空狗 更新时间:2023-10-29 13:49:46 24 4
gpt4 key购买 nike

我用过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 秒后定期关闭自动循环和手动交换 slider 。请让我知道是否有更好的解决方案。

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);
}

关于android - 不同图像的不同持续时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49664799/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com