onconfigurationchanged

Android - detect orientation change, but have interface not respond

Deadly 提交于 2019-12-11 04:28:41
问题 Is it possible in Android to capture screen rotate events but not actually have the activity respond to the rotate events? To make things more difficult, I've got an activity backed by a TabActivity, and in one of the tabs I want to rotate some of the content area on screen - but leave the tab in portrait mode. I've tried setting the activity orientation to portrait in the manifest, but then I no longer get the onConfigurationChanged(..) events. However, If I remove this line, the whole tab

Multiple calls to FragmentTransaction.replace() - only one works after orientation change

試著忘記壹切 提交于 2019-12-11 02:04:39
问题 I am using the following code to populate my UI with 2 fragments, the containers are FrameLayout 's defined in XML. This first time this code is called i.e. when the app starts, it works fine, and both my fragments are displayed as expected. However after a configuration change(specifically, orientation), only the first fragment in the transaction is shown. I don't think it's an issue with the fragments themselves, because if I reverse the code so one replace is called before the other or

Android onConfigurationChanged: how to save and restore fragment back stack?

六月ゝ 毕业季﹏ 提交于 2019-12-10 03:31:59
问题 I have an activity with a dual pane: a list of menu items on the left (fragment M) and details of the currently selected item on the right (fragment D). When the user selects an item in fragment D, fragment D gets replaced with another fragment (let's call it D1). When the user selects an item in fragment D1, fragment D1 gets replaced with another fragment (let's call it D2), and so on. Of course, when the user presses the back button she can go back in the fragments history: D2->D1->D. My

Android: Stop Recreating the activity on orientation change

五迷三道 提交于 2019-12-08 16:05:50
问题 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

Do something right before Screen Rotation?

二次信任 提交于 2019-12-08 14:42:31
问题 i want to do_something() whenever the device rotates from Portrait to Landscape. i have added <activity android:configChanges="orientation" > in my manifest. So onConfigurationChanged() will be called whenever i rotate my device. And it will not re-create the Activity. In my onConfigurationChanged() function: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { do

Why is my Orientation Change Going Unnoticed?

一世执手 提交于 2019-12-08 08:01:44
问题 Based on the accepted answer here, I added this code to an Activity as what I hoped to be the first step in changing the assigned Layout for an Activity: @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Checks the orientation of the screen if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show(); setContentView(R.layout.activity_settings_landscape); } else

Null object reference if configuration changes

回眸只為那壹抹淺笑 提交于 2019-12-07 15:36:16
问题 I get null object reference if configuration changes for only LinearLayout objects. landscape mode I have to setVisiblity = View.GONE for all views except one view portrait mode I have to setVisibility = View.VISIBLE for all views: if (Activity started in portrait mode then turned into landscape) {it work fine} else {it get null object reference only for linearLayout objects} objects return this error are called chart , progress_layout . edited most of class "related code snippet" cause full

In android background image does not change when orientation does

江枫思渺然 提交于 2019-12-07 14:32:51
问题 I have a linear layout for my ActivityGroup as defined <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:mtx="http://schemas.android.com/apk/res/com.matriksdata" android:id="@+id/homeActivityGroupBG" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:background="@drawable/background"> And i have 2 background drawables located in "drawable" and "drawable-land" folders. When orientation changes everything is

EditText data is lost on rotating the device

筅森魡賤 提交于 2019-12-06 08:30:01
OK guys, I am done with it. I have been googling for last 2 days but I can't find the exact solution. Everyone is talking about configChanges and all those cliche things which do not seem to work in my case . I have a login screen which consists of 2 EditTexts. Now this login screen has different layout for both Portrait and Landscape orientation . So I had to create one login.xml in layout folder and another login.xml in layout-land folder. And to support orientation changes I overrid onConfigurationChanged() method in LoginActivity class. In this method I call setContentView(R.layout.login)

Android - Handle Screen Orientation

[亡魂溺海] 提交于 2019-12-06 06:17:17
I'm currently working on an Android application that have different behaviors according to the screen orientation. I'm using getWindowManager().getDefaultDisplay().getRotation() to get the screen orientation in the onCreate() method and manage from there. Basically, my problem is that I need a control over the orientation. In landscape mode, when the user decides it, the application must switch to portrait mode, and stays like that, but only until the use goes to portrait mode, and then again to landscape. I'm using setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) to change