Android: ImageSwitcher getImageId()
Have a question. I'm using image sw开发者_StackOverflowitcher, and this is the way how I set Image to switcher...
imageSwitcher.setImageResource(some_image_id);
So the question is: How to get image id that is set to image switcher ? I cannot find method like imageSwitcher.getImageId();
Thanks...
ImageSwitcher
is a derived class from ViewAnimator
, so you can use:
android.widget.ViewAnimator#getDisplayedChild ()
to get the index of the currently displayed child view, or:
android.widget.ViewAnimator#getCurrentView ()
to get the View corresponding to the currently displayed child.
If you look at the source code, setImageResource(int) adds an ImageView:
public void setImageResource(int resid)
{
ImageView image = (ImageView)this.getNextView();
image.setImageResource(resid);
showNext();
}
精彩评论