Android 在片段中转到另一个片段
您好,在我的片段活动中,我可以控制我希望我的片段位于哪个页面,如下所示Android 在片段中转到另一个片段,android,eclipse,fragment,android-fragmentactivity,Android,Eclipse,Fragment,Android Fragmentactivity,您好,在我的片段活动中,我可以控制我希望我的片段位于哪个页面,如下所示 mIndicator.setCurrentItem(mAdapter.getCount() - 1); 但是在我的片段中,我想进入另一个我已经意识到这段代码不起作用了,这个问题有解决方案吗?请在提问时更具体一些。当我们不知道您的代码是如何编写的时,很难回答 首先,您必须阅读以下内容:,它将教您Android中fragment的基础知识 无论如何,如果我理解正确的话,您需要一个框架布局,以符合要求。下面是一个例子: <
mIndicator.setCurrentItem(mAdapter.getCount() - 1);
但是在我的片段中,我想进入另一个我已经意识到这段代码不起作用了,这个问题有解决方案吗?请在提问时更具体一些。当我们不知道您的代码是如何编写的时,很难回答 首先,您必须阅读以下内容:,它将教您Android中fragment的基础知识 无论如何,如果我理解正确的话,您需要一个
框架布局
,以符合要求。下面是一个例子:
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent" />
您想使is从一个片段移动到另一个片段(初始片段不可见)还是在第一个片段的顶部打开第二个片段?
Fragment mfragment = new yourDummyFragment();
FragmentManager fragmentManager = getSupportFragmentManager(); // The support android library
FragmentTransaction mtransaction = fragmentManager.beginTransaction(); // Initialize the transaction
mtransaction.replace(R.id.xmlOfYourFragment, mfragment);
mtransaction.commit(); // The change starts.