Answer the question
In order to leave comments, you need to log in
How to save state on screen rotation?
There is text TextView nested in ScrollView. How to save the place where you stopped reading when you rotate the screen? According to the tutorial, you need to use: protected void onRestoreInstanceState(Bundle saveInstanceState); protected void onSaveInstanceState(Bundle saveInstanceState); But I do not understand what needs to be written in these methods.
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".old_unused.ActivityBox_1">
<LinearLayout
android:orientation="vertical"
style="@style/RelativeBox">
<TextView
android:id="@+id/Ranishni"
android:text="@string/This_1"
style="@style/Size.text">
</TextView>
</LinearLayout>
</ScrollView>
Answer the question
In order to leave comments, you need to log in
In your case, it will probably be enough to assign an id to the ScrollView using the android:id="name" property and the SDK will save the state automatically when rotated. That is, for example:
<ScrollView
android:id="scroll_name"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".old_unused.ActivityBox_1">
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question