Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8265485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:49:16+00:00 2026-06-08T04:49:16+00:00

I have 2 layouts. The 1st loads (a WebView) fine when the program starts.

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:49:18+00:00Added an answer on June 8, 2026 at 4:49 am

    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

       Button next,previous;
        ViewFlipper vf;
    
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            next = (Button) findViewById(R.id.Button01);
            previous = (Button) findViewById(R.id.Button02);
            next.setOnClickListener(this);
            previous.setOnClickListener(this);
            vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
        }
    
        //@Override
        public void onClick(View v) {
            if (v == next) {
                vf.showNext();
            }
            if (v == previous) {
                vf.showPrevious();
            }
        }
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two layouts, one is the main layout inside which I am including
I have a doubt in layouts.I have designed one layout using group layout using
I created one simple list view. i have two list view, my 1st list
Once I have programmed GUI with Java and have used Form Layouts. Form layout
i have created three linear layouts of equal weights. Inside one of the linear
I have a simple 2 colum layout (left col fixed width 200px, and right
I have an app that runs 2 threads in loops. 1st one is updating
I want to have different layouts like [left|content|right] and [left|content] or [content|right] when using
I am working on several reports all of which have similar layouts I would
Looking at the Android tutorial on: http://developer.android.com/guide/topics/fundamentals/fragments.html ... it seems fragments have their layouts

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.