0

What is the correct (or any) way to remove a view that has been set using setContentView. The application is basically a NativeActivity application that uses openGL and as such has no layouts/views defined. I needed to add a splash screen very early on and so from java create a class derived from SurfaceView to display a resource image. This all works fine and I set the SurfaceView using

    mySurfaceView = new SplashScreen(getApplicationContext());
    setContentView(mySurfaceView);

The problem is i dont seem to be able to remove this view to see my openGl application. I can hear the audio and it seems to be running, but this splash screen is topmost. Ive tried setting visibility, using setContnetView(null), setting a basic blank textview instead, but nothing seems to work.

Any ideas would be great.

Thanks

Adrian Brown
  • 456
  • 3
  • 14
  • it will remove all view and you can setContentView again ((ViewGroup) context.findViewById(android.R.id.content)).removeAllViews(); – Criss Oct 19 '19 at 00:41

2 Answers2

2

setcontentview can be called only once in a activity. You can try to setcontentview in if-else condition but it can be done only once and only in oncreate.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61
  • So its not possible to make it go away to show the openGL once its set? Is it possible to send it to the back or something? – Adrian Brown May 19 '14 at 11:08
  • why not start a new activity after say 3 seconds and finish the splash activity that is how most of us display a splash screen. Also during those 3 seconds do some useful work – Illegal Argument May 19 '14 at 11:09
  • I guess its because its something being added afterwards so it would involve alot of moving around, but i can give it a go :) – Adrian Brown May 19 '14 at 11:11
  • its not true ! setContentView can call more than once – Criss Oct 19 '19 at 00:44
0

There's no unsetContentView(). Use Fragment for your splash screen content and have your SurfaceView there. Add it from code and then remove when done. Or just have set View.GONE visibility on your splash SurfaceView

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141