I have 2 layouts.
The 1st loads (a WebView) fine when the program starts.
The 2nd one also loads (a simple layout) fine when user selects a menu item:
setContentView(R.layout.simple);
LinearLayout ll = (LinearLayout) findViewById(R.id.simple_layout);
All it does is display an image while processing something in the background. When processing is done, it attempts to switch back (via Handler) to the WebView it just obscured.
setContentView(R.layout.main);
The switching seems to occur but the webview is blank.
Why is that? Isn’t setContentView() enough to switch back to the 1st layout just as the switch to 2nd worked fine?
The main problem here is that you shouldn’t call setContentView() several times (as noted in the comments). Fragments are a good idea, but you can also use a ViewFlipper if your just tying to change between 2 views.
Example taken from http://blog.kerul.net/2011/07/viewflipper-examplea-simple-flashcard.html
The reason your screen is blank is because you’ll have to re-init your webview again. If you were to call setContentView() several times, you have to re get your findViewByIds and all that. List view included.