Black screen in ViewFlipper


Last Updated:

  1. mulhearn22

    mulhearn22 New Member This Topic's Starter

    Joined:
    Aug 30, 2010
    Messages:
    3
    Likes Received:
    0
    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 (Text):
    1.  
    2. private void buildImageViews() {
    3.     for (Integer x = 0; x < _imgPointers.length; x++) {
    4.         ImageView i = new ImageView(this);
    5.         i.setId(x);
    6.         setImage(i, x);        
    7.         _flipper.addView(i);    
    8.     }
    9. }
    10.  
    Code to change the view:
    Code (Text):
    1.  
    2. private void changeImage(boolean next) {
    3.     if (next) {          
    4.         _flipper.setOutAnimation(outToLeftAnimation());
    5.         _flipper.setInAnimation(inFromRightAnimation());
    6.     } else {            
    7.         _flipper.setOutAnimation(outToRightAnimation());
    8.         _flipper.setInAnimation(inFromLeftAnimation());
    9.     }
    10.    
    11.     // slide the images
    12.     if (next) {
    13.         _flipper.showNext();    
    14.     } else {
    15.         _flipper.showPrevious();
    16.     }
    17. }
    18.  
    Any help would be awesome!

    TIA,
    Matt
     

    Advertisement
  2. SWhite

    SWhite Member

    Joined:
    Apr 15, 2010
    Messages:
    17
    Likes Received:
    1
    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.
     
  3. mulhearn22

    mulhearn22 New Member This Topic's Starter

    Joined:
    Aug 30, 2010
    Messages:
    3
    Likes Received:
    0
    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
     
  4. mulhearn22

    mulhearn22 New Member This Topic's Starter

    Joined:
    Aug 30, 2010
    Messages:
    3
    Likes Received:
    0
    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!
     
  5. SWhite

    SWhite Member

    Joined:
    Apr 15, 2010
    Messages:
    17
    Likes Received:
    1
    excellent! congrats on the fix
     

Share This Page

Loading...