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
- Delay in loading Html Page(WebView) from assets folder in real android device
- MPAndroidChart method setWordWrapEnabled() not found
- Designing a 'new post' android activity
- Android :EditText inside ListView always update first item in the listview
- Android: Transferring Data via ContentIntent
- Wrong xml being inflated android
- AsyncTask Class
- Unable to receive extras in Android Intent
- Website zoomed out on Android default browser
- Square FloatingActionButton with Android Design Library
- Google Maps API Re-size
- Push toolbar content below statusbar
- Android FragmentPagerAdapter Circular listview
- Layout not shifting up when keyboard is open
- auDIO_OUTPUT_FLAG_FAST denied by client can't connect to localhost
Related Questions in ANDROID-ACTIVITY
- Android - No view found for fragment
- Does a recreated activity remember the original intent started it?
- I want to Show Simple Toast Message When User Click On Media Controller button Pause/Start/Stop in video View Using Media Controller
- Why does this run out of memory? Shouldn't the Activities be released?
- How to check in an (Android) async task if the activity it was called from was finished?
- Android Resources Not Found Exception
- How to handle multiple activity task in android when press home?
- Google Play services LocationSettingsAPI - LocationSettingsRequest Dialog not Showing
- How to land or navigate to previous activity if click on back button
- How to scale the imageview and view with matrix using seekBar?
- how to get the URL from mainActivity to the second activity using intents?
- Coordinator Layout with Toolbar in Fragments or Activity
- NullPointerException error in Android: Unable to instantiate
- ListView OnItemClickListener with a new Activity
- How can i send main activity to inner class inside of Fragment java class?
Related Questions in ONCREATE
- Looping in onCreate method
- onCreate param: 'savedInstance' is allways null
- android camera intent not working properly on some devices
- How to access controls(views)in tabs from another one in android?
- where is best place to get the resources in the activity
- java.lang.NullPointerException and Unknown Source
- I am checking the internet connection at the start of my app and if not connected then it should show a alert message
- How can I make the status bar go back up after being pulled down on an android app?
- Unable to run insert stmt on object SQLErrorCode: 0
- Android - stop and restart app on network connection
- Android Usb Host, singleInstance, onCreate keeps getting called with USB attach
- Can we Call OnCreate() method from another function
- Android Application class method onCreate being called lately
- Which method is called after an intent starts an Activity?
- android how update drawer menu after oncreate method
Related Questions in ONCONFIGURATIONCHANGED
- How to receive onConfigurationChanged events (Android SDK)
- Android app crashes on screen orientation change
- Fixed orientation Activity lifecycle on a slide out keypad phone
- handeling orientation change in android
- android : How to prevent resizing the window when displaying the virtual keyboard
- In android background image does not change when orientation does
- Multiple calls to FragmentTransaction.replace() - only one works after orientation change
- android -Fragments - onConfigurationChanged -it's possible to change only the layout?
- A better way to handle Activity restart on orientation change?
- Orientation change notification in Android
- TextView value doesn't restore when screen is rotated - Android
- Android: Stop Recreating the activity on orientation change
- layout-land is not working?
- How can I make an Android Gallery redraw when a View changes?
- Running an activity inside an activity?
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.