在Eclipse中调试Android的后退堆栈堆栈、Eclipse、Android

2023-09-12 05:35:17 作者:藏不住喜欢

有没有一种方法来可视化与在Eclipse ADT IDE Android中的活动和fragements的backstack?

Is there a way to visualize the backstack with activities and fragements in Android in the Eclipse ADT IDE?

推荐答案

你的意思是只看到它是什么样子的调试目的?在这种情况下,定义

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);
    }
}

在某些类 C 和呼叫

C.displayBackStack(getFragmentManager());

C.displayBackStack(getSupportFragmentManager()); // with compatibility package

这是你的活动。这使BackStack在您的记录。

from your activity. This puts the BackStack in your log.

当然,你可以改变你显示根据您的需要的数据。

Of course, you can vary the data that you display according to your needs.