如何获得在Android的backstack片段条目列表? [英] How to get a list of backstack fragment entries in android?
本文介绍了如何获得在Android的backstack片段条目列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个应用程序中工作的标签实现使用其中 FragmentActivity
。因为,选项卡需要在整个应用程序,片段被广泛用于制作Android上的所有版本的应用程序兼容。
I'm working on an application in which tabs are implemented using FragmentActivity
. Since, tabs are required throughout the application, fragments are used extensively to make the application compatible on all the versions of android.
因此,我在可视化面临的一个问题,什么片段在backstack present。我敢肯定有一个的方法来检索的backstack 的片段present名单。谢谢你。
As a consequence, I'm facing a problem in visualizing as to what fragments are present on the backstack. I'm sure there is a way to retrieve the list of fragments present on the backstack. Thanks.
推荐答案
在 FragmentManager 有方法:
getBackStackEntryCount()
getBackStackEntryAt(INT指数)
FragmentManager fm = getFragmentManager();
for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
Log.i(TAG, "Found fragment: " + fm.getBackStackEntryAt(entry).getId());
}
这篇关于如何获得在Android的backstack片段条目列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文