1

我想要做的是在我的文本视图中阅读段落时以及出于任何原因

我退出了应用程序或者我点击了后退按钮我怎样才能让我的段落保存我正在阅读的地方。

我希望你能理解我,我试过这个,但它不起作用(冻结)

<TextView
        android:id="@+id/id_dailyprayers_txt"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#00000000"
        android:ems="10"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:gravity="center"
        android:shadowColor="@color/black"
        android:shadowDx="2"
        android:shadowDy="2"
        android:shadowRadius="1.5"
        android:text=""
        android:freezesText="true"
        android:textColor="@color/Vanilla"
        android:textSize="35sp" />

有什么帮助吗??

4

1 回答 1

0

您是否尝试过按下后退按钮并保存文本滚动并将其保存在 sharedPreference 中并在应用程序重新打开时加载它。

@Override
public void onBackPressed() {  
getApplicationContext().getSharedPreferences("myData", 0).edit().putInt("lastPos", tv.getScrollY());
super.onBackPressed();
}

并将其放入 onCreat

//first remember to defined tv
tv.scrollTo(0,getApplicationContext().getSharedPreferences("myData", 0).getInt("lastPos", 0)); 

问候

于 2013-09-25T22:24:39.740 回答