我的活动XML
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/contentFrame1"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
</android.support.design.widget.CoordinatorLayout>
我有一个attachView方法,它从活动的onCreate调用
@Override
protected void attachView() {
// Get the fragment from dagger
getFragmentManager().
beginTransaction().
setCustomAnimations(R.animator.slide_up, 0, 0, R.animator.slide_down).
replace(R.id.contentFrame1, new MatchFragment2()).
addToBackStack("MatchFragment").
commit();
getFragmentManager().executePendingTransactions();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
getFragmentManager().
beginTransaction().
setCustomAnimations(R.animator.slide_up, 0, 0, R.animator.slide_down).
replace(R.id.contentFrame1, new VictorFragment()).
addToBackStack("VictorFragment").
commit();
getFragmentManager().executePendingTransactions();
getFragmentManager().getBackStackEntryCount(); //this reads 2
}
}, 3000);
}
VictorFragment不应该是场景中唯一存在的片段,并且从中后退应该退出活动吗?