android-orientation

How do I preserve the state of a selected spinner/dropdown item on orientation change?

微笑、不失礼 提交于 2019-11-29 01:47:33
I am using a spinner dropdown in my code , in which I have 4 to 5 dynamically populated values, say if I have "apples" set to default and I select "oranges" from the dropdown and rotate my screen to landscape from portrait, it goes back to default "apples" along with the view associated with it.How do I save the state such that when I select "oranges" and rotate to landscape, it populates the selected value/remains in the same selected state and keeps the view intact/populates the view that was selected in the portrait mode corresponding to the selected value. Here's the adapter code I use for

Best Way: Save & Restore TextView Position in ScrollView

﹥>﹥吖頭↗ 提交于 2019-11-29 00:37:17
问题 What i want is, upon the device changes orientation, the top line on the screen when in Portrait remains the top line on screen in Landscape. And vice versa. As the width of the screen is likely to be different between Portrait and Landscape, the line width of the text, which means also the width of the TextView and the ScrollView , will vary. Thus, the line-wrap will be different in different screen configurations (Portrait vs. Landscape, large vs. small). The line-break will be at different

how i can break things with Fragments with setRetainInstance(true) and adding them to backstack?

≡放荡痞女 提交于 2019-11-28 16:02:21
问题 the docs on setRetainInstance say : This can only be used with fragments not in the back stack. so I started playing with it. I have one Activity with adds first frag A FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.content, new PackageFragment()); ft.commit then from this frag I run a method from parent Activity which adds frag B to backstack FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft = fm

How to call onClick(View v) method explicitly in an Android? Is it possible?

守給你的承諾、 提交于 2019-11-28 12:42:24
问题 I want to call an onClick(View v) of other class from my activity's method onCreate() . Is it possible? Because I have a Popupwindow in an onClick method of other class, so when an orientation changes, I want my landscape mode's popupwindow to be intact and appear at runtime. How can it be done? Thanks in advance! 回答1: Assuming that the onClick() you want to call is for a View x , use either x.performClick() or x.callOnClick(). Check their javadoc in the Developers Guide for more details.

Best way to persist data between orientation changes in Android

放肆的年华 提交于 2019-11-28 09:10:40
问题 My education application is having a tab host with 6 to 7 tabs with landscape and portrait modes support. In each and every activity associated with a tab, I am showing some student records in list view, with some check boxes for selection and some rating bars, buttons etc. I am getting these student records from remote server through web service call. For some reasons, my app will show one initial relative layout with some buttons after doing some actions/searches It will show results in

Tab Widget Issue when use android:configChanges=“orientation|keyboardHidden” in Grid View but working for other Tab

穿精又带淫゛_ 提交于 2019-11-28 08:55:03
问题 I am stuck with my issue.Thing is that its a custom Tab Widget.In that have multiple tab like Home - News - Abc - PQR . The Activity should be for both orientation like portrait and landscape . so for that each tab have two xml for portrait which is store at layout-port/file.xml and landscape which store at layout-land/file.xml For manage orientation portrait to landscape i have added android:configChanges="orientation|keyboardHidden" rule tag in each activity. TAB_SAMPLE.java Tab file. TAB

Allow rotation/landscape in one fragment

谁说胖子不能爱 提交于 2019-11-28 05:52:39
My app has a single Activity with a FragmentPagerAdapter with four fragments (Using the ViewPagerIndicator library). One of these fragments has designs for both a separate portrait and landscape layout, the other three do not and need to be fixed to portrait orientation. My thought was to set android:configChanges="orientation" in the manifest and call getActivity().setRequestedScreenOrientation() in the onResume() of all the fragments, locking to SCREEN_ORIENTATION_PORTRAIT in three of them but to SCREEN_ORIENTATION_UNSPECIFIED in the one that needs to allow rotation, but this doesn't work.

How to create a BottomBar as StickyBottomCaptureLayout in camera2 Android api?

大城市里の小女人 提交于 2019-11-28 02:04:16
问题 Context: In the android-7.1.1_r12 api, the android.hardware.camera2 uses a StickyBottomCaptureLayout as a "BottomBar" to display the action buttons (as switch-camera, shutter and recent picture buttons). Whatever the device orientation, this StickyBottomCaptureLayout is displayed always above/near the system bar (which has back, home and other apps buttons). For example, this is what it looks when the rotation degree is 0 or 180 : And, by orienting the device and get a rotation degree as 90

how to save state with onSaveInstanceState and onRestoreInstanceState while orientation change

北慕城南 提交于 2019-11-28 01:54:47
问题 I read almost all article about onSaveInstanceState and onRestoreInstanceState in Stack overflow but I cant solve my problem. I have a text view and button in my main.java and while you click on button value of a ( a is an int variable) variable will increase and show in the text view, but, when I rotate my phone ( orientation change), text view reset. I override onSaveInstanceState and onRestoreInstanceState but it doesn't work. one more thing, I have special layout-land.xml file for

Camera capture orientation on samsung devices in android

南笙酒味 提交于 2019-11-27 20:44:56
I am creating a camera app. The image when captured is shown in the grid view. Now, the code is working completely fine on all the devices except for samsung devices. I am facing the orientation issue. When I capture an image in a portrait mode, the image rotates when displayed in the gridview. I have not kept any rotate code. Secondly, with the EXIF I achieved the proper image in the grid view but when the device orientation changes, again the image rotates in a wiered fashion. Attaching images: Sorry for the resolution of the image. Please lemme know if they are not visible properly. Will