获取当前的片段对象
在我main.xml我有 <FrameLayout android:id="@+id/frameTitle" android:padding="5dp" android:layout_height="wrap_content" android:layout_width="fill_parent" android:background="@drawable/title_bg"> <fragment android:name="com.fragment.TitleFragment" android:id="@+id/fragmentTag" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </FrameLayout> 我像这样设置片段对象 FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); Fragment newFragment = new FragmentType1(); fragmentTransaction.replace(R.id.frameTitle, casinodetailFragment, "fragmentTag"); // fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); 它FragmentType2,FragmentType3,...在不同的时间设置不同类型的Fragment对象()。现在在某个时间点,我需要确定当前存在哪个对象。 在短,我需要做这样的事情: Fragment currentFragment = //what is the way to get current fragment object in FrameLayout …