I got this to work no without the ViewFlipper.  I think that there
should be information in the ViewFlipper class
that it doesn't support SurfaceView. I lost many hours of work because
of this. The reason I used the ViewFlipper class for SurfaceView was
that other threads on this forum recommended it, like this one:

https://groups.google.com/group/android-developers/browse_thread/thread/6e40d73d0883d150/e6da11407f5ac488?lnk=gst&q=switch+between+GLSurfaceView#e6da11407f5ac488

So there are other developers who have made the same mistake.

On Sep 20, 3:51 pm, MobileVisuals <eyv...@astralvisuals.com> wrote:
> How can I then switch between a view with 2d rendering and a view with
> 3d rendering?
>
> I suppose I have to use GLSurfaceView for 3d rendering with OpenGL?
>
> On Sep 20, 3:00 pm, Jens <dunkingbikk...@gmail.com> wrote:
>
> > That would be the gist of what both Dianne & Romain Guy said yes.
>
> > On Sep 20, 2:13 pm, MobileVisuals <eyv...@astralvisuals.com> wrote:
>
> > > GLSurfaceView extends SurfaceView. Does that mean that it is not
> > > possible to animate GLSurfaceView with a viewflipper?
>
> > > On Sep 20, 9:54 am, Romain Guy <romain...@android.com> wrote:
>
> > > > You can animate another view on top of a SurfaceView, you just cannot
> > > > animate the SurfaceView itself.
>
> > > > On Tue, Sep 20, 2011 at 12:51 AM, MobileVisuals 
> > > > <eyv...@astralvisuals.com>wrote:
>
> > > > > Thanks for the info, I have spent many hours investigating this issue
> > > > > and now I finally know what the problem is. My app has a standard 2d
> > > > > menu. It is possible to view different 3d visual effects from the
> > > > > menu. The 3d visual effects are rendered in a GLSurfaceView. That
> > > > > class extends SurfaceView.
>
> > > > > You say that SurfaceView should not be used in a ViewFlipper. How can
> > > > > I implement my app if I can't use SurfaceView or GLSurfaceView? Which
> > > > > type of view should I use for the ViewFlipper? Can I render the 3d
> > > > > visual effects with other views than GLSurfaceView?
>
> > > > > Or shouldn't I use a ViewFlipper at all? If not, how can I then switch
> > > > > between the 2d and the 3d rendering?
>
> > > > > On Sep 19, 7:37 pm, Dianne Hackborn <hack...@android.com> wrote:
> > > > > > Don't use a SurfaceView in a ViewFlipper.
>
> > > > > > Nor a ListView.
>
> > > > > > SurfaceView is a *very* *special* view.  As it says, what it does is
> > > > > create
> > > > > > a completely separate surface (a.k.a. window) that is associated 
> > > > > > with
> > > > > your
> > > > > > main window.  This window is positioned behind the main window, and 
> > > > > > a
> > > > > hole
> > > > > > punched through your main window to see the surface behind.
>
> > > > > > By its nature, this makes the interaction between the surface of the
> > > > > surface
> > > > > > view and the main view hierarchy limited.
>
> > > > > > The purpose of SurfaceView is to present static things like video
> > > > > playback
> > > > > > or a game playfield in its own surface so that it can draw outside 
> > > > > > of the
> > > > > > normal view hierarchy update model (and use OpenGL drawing, 
> > > > > > different
> > > > > color
> > > > > > spaces, etc).  It is not to give a tight integration with the rest 
> > > > > > of the
> > > > > > view hierarchy.
>
> > > > > > You should essentially think of it as an overlay, because really 
> > > > > > that is
> > > > > > what it is.
>
> > > > > > On Mon, Sep 19, 2011 at 10:29 AM, MobileVisuals <
> > > > > eyv...@astralvisuals.com>wrote:
>
> > > > > > > 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
> > > > > android-developers@googlegroups.com
> > > > > > > To unsubscribe from this group, send email to
> > > > > > > android-developers+unsubscr...@googlegroups.com
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > > > --
> > > > > > Dianne Hackborn
> > > > > > Android framework engineer
> > > > > > hack...@android.com
>
> > > > > > Note: please don't send private questions to me, as I don't have 
> > > > > > time to
> > > > > > provide private support, and so won't reply to such e-mails.  All 
> > > > > > such
> > > > > > questions should be posted on public forums, where I and others can 
> > > > > > see
> > > > > and
> > > > > > answer them.
>
> > > > > --
> > > > > You received this message because you are subscribed to the Google
> > > > > Groups "Android Developers" group.
> > > > > To post to this group, send email to 
> > > > > android-developers@googlegroups.com
> > > > > To unsubscribe from this group, send email to
> > > > > android-developers+unsubscr...@googlegroups.com
> > > > > For more options, visit this group at
> > > > >http://groups.google.com/group/android-developers?hl=en
>
> > > > --
> > > > Romain Guy
> > > > Android framework engineer
> > > > romain...@android.com

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to