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

  • Home
  • SEARCH
  • 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 7703193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:24:06+00:00 2026-05-31T23:24:06+00:00

I’ve an android app that has multiple views. I’ve disabled the automatic orientation switching

  • 0

I’ve an android app that has multiple views. I’ve disabled the automatic orientation switching by declaring android:configChanges="keyboardHidden|orientation|screenSize" for my activity.

Q1) How I should re-activate views in onConfigurationChanged()? It seems I need to reset the content view using setContentView method. Is there an alternative way to signal view that now you should inflate the landscape/portrait version of the layout? Some of my views contain quite complicated states/modeless dialogs etc that can appear any time so deleting the view object and re-instantiating it just doesn’t sound right.

Q2) What’s the best way in onConfigurationChanged() to know which view we should actually now activate i.e. what was focused when orientation change was initiated? I’m reluctant to rely on getCurrentFocus() as it can be null sometimes.

  • 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-05-31T23:24:07+00:00Added an answer on May 31, 2026 at 11:24 pm

    Q1) How I should re-activate views in onConfigurationChanged()?

    As you mentioned, setContentView() is a good way to do this. Just remember to not always pass in a layout XML to this method. Instead, pre-inflate your layout into a View object and pass in that View object to setContentView. That way, you don’t incur the cost of re-creating your view object on every orientation change.

    The following is a sample code – may not work as-is; but meant to illustrate my point.

    View mLandscapeView;
    View myPortraitView
    
    protected void onCreate(Bundle bundle){
        View myLandscapeView = getLayoutInflater().inflate(R.layout.my_landscape, null);
        View myPortraitView = getLayoutInflater().inflate(R.layout.my_portrait, null);
        //...
    }
    
    @Override
    protected void onConfigurationChanged(Configuration config){
        if(config.orientation = Configuration.ORIENTATION_LANDSCAPE){
            //adjust mLandscapeView as needed
            setContentView(mLandscapeView);
        }
    
        // And so on ... 
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a

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.