本文介绍了Android的ImageSwitcher例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能给我一个ImageSwitcher的工作示例没有一个画廊?

Can anyone give me a working example of an ImageSwitcher without a Gallery?

下面是我的code:

         ImageSwitcher mImageSwitcher;
         mImageSwitcher = new ImageSwitcher(this);
         mImageSwitcher.setLayoutParams(new
                ImageSwitcher.LayoutParams(
                           LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT));

        mImageSwitcher.setInAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_in));
        mImageSwitcher.setOutAnimation(AnimationUtils.loadAnimation(this,
                android.R.anim.fade_out));
        mImageSwitcher.setFactory(this);

和我这样做是为了显示新的画面:

And I do this to display a new picture:

        Drawable d = new BitmapDrawable(bitmap);
        mImageSwitcher.setImageDrawable(d);

确定,这将导致动漫新形象。如何设置这个动画的previous形象?

OK, this causes animation to the new image. How do I set the previous image in this animation?

有此显示两幅图像,previous和下一个。我知道如何设置下的形象。我想知道如何设置previous。我期望这是当前显示的图像,但是这似乎并不正确。

There are two images displayed here, "previous" and "next". I know how to set the "next" image. I would like to know how to set "previous". I would expect that to be the image currently displayed, but that does not seem to be correct.

推荐答案

您可以设置setImageDrawable方法下一个图像。当然,接下来的图像可以是你的previous形象!例如:

You can set the next image with setImageDrawable method. Of course next image can be your previous image! for example:

setImageDrawable(preimage)

这篇关于Android的ImageSwitcher例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 20:34