从活动的数据发送到动态地分段 [英] send data from activity to fragment dynamicly

查看:167
本文介绍了从活动的数据发送到动态地分段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我怎么能在活动数据发送到片段的动态地

As the title said,how can I send data from activity to fragment dynamicly?

例如,每次当我改变活动的价值,当触发事件的时候,我必须将此值转移到片段,则该片段将根据此值的一些变化。

For example,every time when I change the value in activity when trigger the event,I must transfer this value to fragment,then the fragment will make some changes according this value.

请注意,它是动态的,而不是:

Notice that it is dynamic,instead of :

public static VideoFragment instance(String videourl, String bannerurl) {
        VideoFragment fragment = new VideoFragment();
        Bundle bundle = new Bundle();
        bundle.putString("videourl", videourl);
        bundle.putString("bannerurl", bannerurl);
        fragment.setArguments(bundle);
        return fragment;
    }

这发生在初始化片段和不符合要求

This occurs when initialize the fragment,and it does not meet the requirement.

请告诉我该如何处理呢?

Please tell me how to handle with it?

感谢

推荐答案

如果您添加一个方法到你的VideoFragment类,可以直接调用fragment.methodName(参数参数);您所创建的片段之后。

If you add a method to your VideoFragment class, you can directly call fragment.methodName(Param param); after you have created the fragment.

这篇关于从活动的数据发送到动态地分段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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