I have a listview with two buttons in my main.xml layout. On click of one button i'am creating a textview dynamically and adding it at the bottom of the screen to confirm the user interaction. When the user clicks 2nd button (Confirm button), i need to add that text to listview. To support landscape mode, i have the same layout file in layout-land folder. When i click on 1st button it is creating a textview with some text and adding at bottom of the screen. Now if a change the device orientation then it is loading the landscape main.xml and activity is recreating again. So my textview is getting collapsed. How can i prevent that the recreation of activity on orientation change. (But it should pick up the other layout file).
Android: Stop Recreating the activity on orientation change
19.8k views Asked by sachi At
2
There are 2 answers
0
Mina Fawzy
On
You should add screenSize
if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).
Added in API level 13.
then it should be like this
<activity
android:configChanges="keyboardHidden|orientation|screenSize"
android:name=".testActivity"
android:label="@string/app_name"></activity>
http://developer.android.com/guide/topics/manifest/activity-element.html
Related Questions in ANDROID
- Creating global Class holder
- Flutter + Dart: Editing name of a tab shows up a black screen
- android-pdf-viewer Received status code 401 from server: Unauthorized
- Sdk 34 WRITE_EXTERNAL_STORAGE not working
- ussd reader in Recket Native module
- Incorrect display of LinearGradientBrush in IOS
- The Binary Version Of its metadata is 1.8.0, expected Version is 1.6.0 build error
- I can't make TextInput to auto expand properly in Android
- Creating multiple instances of a class with different initializing values in Flutter
- How to create a lottie animation
- making android analyze with coverity sast tool
- Flutter plugin development android src not opening after opening example
- I initialize my ViewModel in the Activity with several fragments as tabs, but the fragments(tabs) return null for the updated livedata
- Node.js Server + Socket.IO + Android Mobile Applicatoin XHR Polling Error...?
- How I can use the shared preferences class?
Related Questions in ANDROID-ACTIVITY
- Jetpack Compose how to reverse edge-to-edge when leaving composition
- In Android Studio, how make an item in the recyclerview open another activity when clicked?
- How to detect the Minimization of Custom Chrome Tabs on Android?
- Activity status in Node js
- setTaskDescription does not change the icon
- How to launch android activity in background, or minimized, when screen locked in Android 14 and start the activity with broadcast intent
- Window Manager cant create view
- Android AppWidget PendingIntent Activity Transition Animation
- How to clear intermediate activities in Android?
- How to add two activity in android studio using Kotlin?
- How to hide Android systembars & navigationbars without blocking floating widgets from being closable?
- Which Android component to use for orchestration (automatism)?
- onNewIntent() method called multiple times
- Google Files not respecting singleInstance launchMode
- Switch off noHistory="true" programmatically
Related Questions in ONCREATE
- Adding new TextViews to ConstraintLayout doesn't work onCreate but works afterwards
- Activity not being created
- Delphi TWinControl duplicating its children at runtime
- Android Activity.onCreate is called twice when using foreground NFC dispatching
- Delphi 11 FormCreate not called
- Is it normal for onCreate() to be called twice during first installation of Android app?
- Save buton id the first time you run an app
- SavedInstanceState of the MainActivity is null when click back button on the top left of the SecondActivity
- Android screen rotation not working as expected
- When I open the activity for the first time or while using the app after it's destroyed, it shows a white screen for a few seconds?
- Activity Life Cycle: How can a new activtiy come to the foreground before being created?
- How to get adapter position in onCreate of RecyclerView.ViewHolder in Android
- How to get access of oncreate variable accesss with in the ActivityResultLauncher Method Android
- onCreate method in Android studio
- unable to hook onCreate() using frida for android application
Related Questions in ONCONFIGURATIONCHANGED
- onConfigurationChanged() is not getting called on Android 13 and 14
- Calling ActionMode finish() in onConfigurationChanged() can lead to redraws
- Android UI Doubles after Configuration Change
- How can I handle the Configuration Change caused by switching System Navigation whilst Xamarin.Forms app backgrounded?
- "IllegalArgumentException: ID does not reference a View inside this Activity exception" when calling findNavController(activity, id) in onViewCreated
- With a change of configuration, the fragments are not redesigned
- how to handle view rotations like youtube do on android?
- How handle Android Device 180 degree rotation (reverseLandscape)? - onConfigurationChanged is not called
- how to make textureview to not be affected by configuration changes?
- android recyclerView's view item's onConfigurationChanged is not called
- Java Android Badge Drawable not working properly after configuration change
- Android navigation component resets to start destination after configuration change
- onConfigurationChanged is not working for API17
- Is there a configChanges for Invert Colors modification
- Resources$NotFoundException after configuration change in dynamic feature module
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Just edit the Activity Tag in androidmanifest.xml.