Android 如何在现有片段中获取bundle

Android 如何在现有片段中获取bundle,android,android-fragments,Android,Android Fragments,如何在我将包传递到现有片段中而不重新创建包后获取包。我只是显示和隐藏我的片段。方法onResume()在transaction.commitNow()之后不调用。我在fragment中考虑了方法update(),但我无法在androidfragment.class中创建它。我如何通知我现有的片段,该包已通过 我传递包的导航器方法 导航器: @PublishedApi internal fun goTo(tag: String, keepState: Boo

如何在我将包传递到现有片段中而不重新创建包后获取包。我只是显示和隐藏我的片段。方法
onResume()
transaction.commitNow()之后不调用。我在fragment中考虑了方法
update()
,但我无法在android
fragment.class
中创建它。我如何通知我现有的片段,该包已通过

我传递包的导航器方法

导航器:

  @PublishedApi
internal fun goTo(tag: String,
                  keepState: Boolean,
                  withCustomAnimation: Boolean,
                  args: Bundle,
                  backStrategy: BackStrategy
                  ){
    if(activeTag == tag){
        return
    }

    if(!fragmentMap.containsKey(tag) || !keepState) {
        val fragment = Fragment.instantiate(activity, tag)
        if (!args.isEmpty) {
            fragment.arguments = args
        }

        if (!keepState) {
            val weakFragment = fragmentManager.findFragmentByTag(tag)
            weakFragment?.let {
                fragmentManager.inTransaction {
                    remove(weakFragment)
                }
            }
        }
        fragmentManager.inTransaction {
            addOpenAnimation(this, withCustomAnimation)
            add(containerId, fragment, tag)
        }
        fragmentMap.put(tag, Screen(fragment, backStrategy))

        if (activeTag == null) {
            rootTag == tag
        }
    }else{
        val fragment = fragmentMap[tag]?.fragment
        if(!args.isEmpty){
            fragment?.arguments = args
        }
        fragmentMap.put(tag, Screen(fragment!!, backStrategy))

        if (activeTag == null) {
            rootTag == tag
        }
    }
    fragmentManager.inTransaction {
        addOpenAnimation(this, withCustomAnimation)
        fragmentMap
                .filter {
                    it.key != tag
                }
                .forEach {
                    hide(it.value.fragment)
                }
        show(fragmentMap[tag]?.fragment)
        commit()
    }
    activeTag = tag
    invokeFragmentChangeListener(tag)

    fragmentMap.replaceValue(tag, fragmentMap[tag])


}

您可以在片段中获取捆绑包:

@Override
public void onCreate(Bundle savedInstanceState) {
    Bundle bundle = getArguments();
    ....
}
public void notifyBundleUpdated() {
    Bundle bundle = getArguments();
    ....
}
或者在片段中调用您自己的方法:

@Override
public void onCreate(Bundle savedInstanceState) {
    Bundle bundle = getArguments();
    ....
}
public void notifyBundleUpdated() {
    Bundle bundle = getArguments();
    ....
}

我不能。我的所有片段都是从android support Fragment.class扩展而来的。我没有权限使用我自己的方法您可以将您自己的方法添加到您的classi know中,但我不能从
goTo
中的
fragment
调用它,因为它的类型是
supportFragment
,您可能喜欢并且