在Eclipse中调试Android的后退堆栈 [英] Debug the Android back stack in eclipse

查看:87
本文介绍了在Eclipse中调试Android的后退堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来可视化与在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.

这篇关于在Eclipse中调试Android的后退堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆