如何通过片段之间的数据 [英] How to pass data between fragments

查看:106
本文介绍了如何通过片段之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着通过我的方案二片段(fragments)之间的数据。存储在列表它只是一个简单的字符串。这份名单是在一个片段公开,当用户点击一个列表项目,我需要它出现在片段B.内容提供商似乎只支持ID的,所以这是行不通的。有什么建议?

Im trying to pass data between two fragmens in my program. Its just a simple string that is stored in the List. The List is made public in fragments A, and when the user clicks on a list item, I need it to show up in fragment B. The content provider only seems to support ID's, so that will not work. Any suggestions?

推荐答案

我觉得片段之间的沟通应通过活动来完成。和碎片和活动之间的通信可以做这样的http://developer.android.com/guide/topics/fundamentals/fragments.html#CommunicatingWithActivity.

I think communication between fragments should be done via activity. And communication between fragment and activity can be done this way http://developer.android.com/guide/topics/fundamentals/fragments.html#CommunicatingWithActivity.

这篇关于如何通过片段之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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