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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:57:00+00:00 2026-05-13T13:57:00+00:00

Currently I am working on an Android application that is dynamically creating controls. Everytime

  • 0

Currently I am working on an Android application that is dynamically creating controls. Everytime a user would click a button a new EditText appears below the button and the user can interact with the EditText. However if the screen orientation changes, the EditText’s that the user created also disappears.

Code sample of user creating a EditText: (located in a onClick(), p is basic layoutParamas, and layout is a LinearLayout located undearneath the button)

    EditText editText = new EditText(this);
    layout.addView(buttonView, p);

Wondering what would be the easiest way to save the layout when the screen orientation changes so I do not loose any of the controls, or am I dyanmically creating the controls wrong.

Thanks.

update: By overriding the onSaveInstanceState() I was able to save a object which contained a list of all the controls the user orignally added. Using this list I was able to create the controls in the onCreate().

Still curious if there is an easier way to accomplish this task, as I would have to refactor a lot of code to fully implement this method.

  • 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-13T13:57:00+00:00Added an answer on May 13, 2026 at 1:57 pm

    Try adding this to your <activity> tag in your manifest file:

    android:configChanges="orientation|keyboardHidden"
    

    Then do this in the activity class:

    @Override
    public void onConfigurationChanged(final Configuration newConfig)
    {
        // Ignore orientation change to keep activity from restarting
        super.onConfigurationChanged(newConfig);
    }
    

    If you do this your activity will just be reused on orientation change instead of destroyed/recreated. So you won’t have to save the state of everything you have going on.

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

Sidebar

Ask A Question

Stats

  • Questions 312k
  • Answers 312k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No. You have to include them all if that's what… May 13, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer Here's what did the trick. In my environment.rb file, I… May 13, 2026 at 10:33 pm
  • Editorial Team
    Editorial Team added an answer If you want to : get what is on the… May 13, 2026 at 10:33 pm

Related Questions

With today's modern mobile phones, is it still worth programming the mobile version of
I am working on an application that loads plugins at startup from a subdirectory,
I am working on an fairly simple CRUD application in ASP.NET MVC. The rule
I am working on an application that installs a system wide keyboard hook. I
I am working on an MVC site that is the first my company has

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.