• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Black screen in ViewFlipper

Hi,

I have a ViewFlipper. All is well, except between my first and last view is a solid black screen that I didn't add. Anyone have any ideas on why this is and how to get rid of it?

Code to populate ViewFlipper:
Code:
private void buildImageViews() {
    for (Integer x = 0; x < _imgPointers.length; x++) {
        ImageView i = new ImageView(this);
        i.setId(x);
        setImage(i, x);        
        _flipper.addView(i);    
    }
}
Code to change the view:
Code:
private void changeImage(boolean next) {
    if (next) {           
        _flipper.setOutAnimation(outToLeftAnimation());
        _flipper.setInAnimation(inFromRightAnimation());
    } else {            
        _flipper.setOutAnimation(outToRightAnimation());
        _flipper.setInAnimation(inFromLeftAnimation());
    }
    
    // slide the images
    if (next) {
        _flipper.showNext();    
    } else {
        _flipper.showPrevious();
    }
}
Any help would be awesome!

TIA,
Matt
 
got me beat...

only suggestion i have is to try changing bounds on your loop from .length to .length-1

my guess is that your pointer list size that is returned is one index larger than you have images for.
 
Thank you for your response.

I tried that, thinking the same thing. It ended up taking one of my pictures away, leaving the black screen. It's not like I'm manually changing the indexes of the displaying image. Looks to me like an Android bug, but I haven't been able to find squat on the web. Is it a feature where in between the last and first views is a black screen? That would make sense if the control was used only for images, but you never know.

Anyone have any clues?

TIA,
Matt
 
Figured it out.

Turns out, when you instantiate the ViewFlipper, it automatically adds a view, which I did not clear before adding my own. By calling _flipper.removeAllViews() before populating, I got rid of that sucker.

Hope this helps someone else!
 
Back
Top Bottom