5
我有一个类型为FragmentActivity的活动。从片段输入新活动并返回时片段活动被破坏
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".OpenStack" >
<!--
This title strip will display the currently visible page title, as well as the page
titles for adjacent pages.
-->
<android.support.v4.view.PagerTitleStrip
android:id="@+id/pager_title_strip"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#33b5e5"
android:paddingBottom="4dp"
android:paddingTop="4dp"
android:textColor="#fff" />
</android.support.v4.view.ViewPager>
当用户点击该项目在列表中,我打开一个新的活动像这样的片段里面:
Intent myIntent = new Intent(getActivity(), InstanceActivity.class);
getActivity().startActivity(myIntent);
里面我使用视图寻呼机,其中每个滚动标签是片段有一些内容
但是,当我在InstaceActivity中单击回到具有碎片的碎片时,它将被销毁并再次创建。我不知道为什么会发生。我应该做一些特殊的事情来保持FragmentActivity在后台吗?
它甚至不利于保存状态:
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("CONNTOKEN", isConnToken);
outState.putString("NOVAURL", isNovaURL);
}
因为在FragmentActivity的OnCreate事件的savedInstanceState是NULL当我按回?
从我的理解,这是用于从片段到另一个片段时,但在这里我要从片段到活动。 – andy57
哦......我明白了。你尝试过这种方法吗?它不起作用? – nhgrif
我不会在这里更改片段,我只能在FragmentTransaction上使用addToBackStack。无论如何我都试过,但它没有改变任何东西。 – andy57