My app uses a ViewFlipper. It is possible to flip between the views without problems at first.But after switching to another app and then switching back to the ViewFlipper app, it is not possible to flip between the views. One of the views is always displayed as just a black screen.
I have investigated the reason for this, using the simplest possible SurfaceView. It is still the same problem. It is not a thread problem, I see that the onDraw method is called like it should. What is the reason for this? Doesn't the ViewFlipper class support SurfaceView like it should? I got the code for the SurfaceView from the basic tuturial: http://www.edu4java.com/androidgame/androidgame2.html and the code for the View flipper from Mark Murphys View flipper tutorial: https://github.com/commonsguy/cw-android/tree/master/Fancy/Flipper1 This is my code: ----------------------------- public class FlipperDemo2 extends Activity { ViewFlipper flipper; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); flipper=(ViewFlipper)findViewById(R.id.details); GameView lv=new GameView(this.getApplicationContext(),true); flipper.addView(lv, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); GameView lv2=new GameView(this.getApplicationContext(),false); flipper.addView(lv2, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT)); flipper.setFlipInterval(2000);//2000 flipper.startFlipping(); } } ---------------------------------- public class GameView extends SurfaceView { private SurfaceHolder holder; boolean blue; public GameView(Context context,boolean _blue) { super(context); holder = getHolder(); blue=_blue; holder.addCallback(new SurfaceHolder.Callback() { @Override public void surfaceDestroyed(SurfaceHolder holder) { } @Override public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(null); onDraw(c); holder.unlockCanvasAndPost(c); } @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } }); } @Override protected void onDraw(Canvas canvas) { if(blue) canvas.drawColor(Color.YELLOW); else canvas.drawColor(Color.GREEN); } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

