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 8278297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:57:48+00:00 2026-06-08T08:57:48+00:00

In my main layout (mainlayout) I am displaying some text and images which are

  • 0

In my main layout (mainlayout) I am displaying some text and images which are set dynamically based on the actions of the user. For one particular button click I need to display the contents of another layout (secondlayout). I do this using:

 setContentView(R.layout.secondlayout);

On the second layout I have another button that I use to return to the main layout, once again using:

 setContentView(R.layout.mainlayout);

The problem is on displaying the mainlayout again all the text and images I was displaying have now disappeared.

How can I return to the mainlayout and still display the contents I was displaying?

  • 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-08T08:57:49+00:00Added an answer on June 8, 2026 at 8:57 am

    don’t do it that way. setContentView() is meant to be called once in your onCreate() method. however, couple of reasonable ways to do it,

    1. encapsulate each layout in a fragment, then show / hide each fragment as needed.
    2. bundle both layouts into a single layout, and show / hide each section of the layout by calling setVisibility() on the layout’s outermost container.
    • 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 main layout in which I'd like to sequentially display / hide
I want to create one button/layout object dynamically from the object that exist on
I have created linearlayout with layout:height=fill_parent I have set 3 buttons and one TextView.
My application.html.erb (main layout) has some categories on the top of the header, and
I wish to list some Categories name on my layout main.php page. Since the
so I have my main layout as such: <div class=menu> <?php include('/menu.php'); ?> </div>
I'm making a widget for a Yii application. The main layout view registers all
I am confused here. What my program do: displays a view( main layout) that
I have two panels: main_panel child_panel The main_panel layout is set using: main_panel.setLayout(flowlayout) I

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.