为什么FragmentManager的getBackStackEntryCount()返回零? [英] Why FragmentManager's getBackStackEntryCount() return zero?

查看:361
本文介绍了为什么FragmentManager的getBackStackEntryCount()返回零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private static void changeFragment(Fragment f, boolean init) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.info_content, f,f.getClass().getName());
        if(!init){
            ft.addToBackStack(null);
        }
        ft.commit();
    }

当我想要得到的协议栈通过调用fm.getBackStackEntryCount(COUT),它返回零?

when I want to get the stack cout by call fm.getBackStackEntryCount(), it returns zero?

推荐答案

您得叫 fm.executePendingTransactions() ft.commit ()或之前 fm.getBackStackEntryCount()。由于提交()只时间表以后通的交易。

You have to call a fm.executePendingTransactions() after ft.commit() or before fm.getBackStackEntryCount(). Because the commit() only schedules the transactions for a later pass.

这篇关于为什么FragmentManager的getBackStackEntryCount()返回零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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