Is there a way to visualize the backstack with activities and fragements in Android in the Eclipse ADT IDE?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Do you mean just see what it looks like for debugging purposes? In that case, define
public static void displayBackStack(FragmentManager fm) {
int count = fm.getBackStackEntryCount();
Log.d("Backstack log", "There are " + count + " entries");
for(int i = 0; i<count; i++) {
// Display Backstack-entry data like
String name = fm.getBackStackEntryAt(i).getName();
Log.d("Backstack log", "entry " + i + ": " + name);
}
}
in some class C
and call
C.displayBackStack(getFragmentManager());
or
C.displayBackStack(getSupportFragmentManager()); // with compatibility package
from your activity. This puts the BackStack in your log.
Of course, you can vary the data that you display according to your needs.