片段及其容器活动之间传递数据 [英] Passing data between a fragment and its container activity

查看:110
本文介绍了片段及其容器活动之间传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能片段及其容器活动之间传递数据?有没有通过类似的意图传递活动之间数据的东西吗?

How can i pass data between a fragment and its container activity? Is there something similar to passing data between activities through intents?

我读到这样的:<一href="http://developer.android.com/guide/topics/fundamentals/fragments.html#CommunicatingWithActivity">http://developer.android.com/guide/topics/fundamentals/fragments.html#CommunicatingWithActivity

但它并没有多大帮助。 任何帮助AP preciated

But it didn't help much. Any help is appreciated

推荐答案

在你的片段,你可以调用getActivity()。这会给你访问创建该片段的活性。从这里可以很明显的调用都在活动的任何形式的访问方法。

In your fragment you can call getActivity(). This will give you access to the activity that created the fragment. From there you can obviously call any sort of accessor methods that are in the activity.

这篇关于片段及其容器活动之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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