[android-developers] Re: Fragment question: inter-fragment communication?

2011-02-28 Thread Gregg Reno
Thanks for all the help on this. I'm not the greatest Java programmer, but thought I would share my code in case it's useful to anyone else. In my case, I'm trying to replicate the functionality similar to the email client. I have 3 fragments - a list view, a gallery view, and a content view.

[android-developers] Re: Fragment question: inter-fragment communication?

2011-02-27 Thread Gregg Reno
Maybe this covered earlier in this thread and I'm still not understanding it. I like the idea of a each fragment communicating back to the activity rather than to other fragments. Then the activity can decide whether it needs to send information to other fragments. So is there an existing

Re: [android-developers] Re: Fragment question: inter-fragment communication?

2011-02-27 Thread Dianne Hackborn
Fragment.getActivity().doSomething(). A little more formally, define an interface for the fragment to call back on the activity it is running in, which each activity using that fragment can implement. On Sun, Feb 27, 2011 at 6:39 PM, Gregg Reno gregg.r...@gmail.com wrote: Maybe this covered

Re: [android-developers] Re: Fragment question: inter-fragment communication?

2011-02-27 Thread Gregg Reno
OK, that makes sense. Thanks Dianne. -Gregg On Feb 27, 2011 9:53 PM, Dianne Hackborn hack...@android.com wrote: Fragment.getActivity().doSomething(). A little more formally, define an interface for the fragment to call back on the activity it is running in, which each activity using that

[android-developers] Re: Fragment question: inter-fragment communication?

2011-02-27 Thread davemac
A little more formally, have your activity implement an interface such as OnMyFragmentListener, so that the activity must implement a method like onFragmentDidSomething(). When your fragment wants to send something to the activity, it can do the following:

Re: [android-developers] Re: Fragment question: inter-fragment communication?

2011-02-27 Thread Dianne Hackborn
You can also do the cast in Fragment.onAttach() if you want to fail quickly in the case of someone forgetting to implement the interface. On Sun, Feb 27, 2011 at 8:59 PM, davemac davemac...@gmail.com wrote: A little more formally, have your activity implement an interface such as

[android-developers] Re: Fragment question: inter-fragment communication?

2011-02-18 Thread davemac
I had seen and appreciate the putFragment() method of FragmentManager. Quick follow-on question on that: you aren't necessarily guaranteed to get back the same in-memory instance of a fragment saved with putFragment() when you call getFragment(), but you won't be able to tell the difference,

Re: [android-developers] Re: Fragment question: inter-fragment communication?

2011-02-18 Thread Dianne Hackborn
On Fri, Feb 18, 2011 at 5:19 AM, davemac davemac...@gmail.com wrote: I had seen and appreciate the putFragment() method of FragmentManager. Quick follow-on question on that: you aren't necessarily guaranteed to get back the same in-memory instance of a fragment saved with putFragment() when

[android-developers] Re: Fragment question: inter-fragment communication?

2011-02-17 Thread Streets Of Boston
Your 'activity' idea seems to be the best one. Fragments can be used to better separate Views from Controllers, where Fragments (and it constituent child-views) are the Views and Activities are the Controllers (note that Activities would still 'directly' update the action-bar, the title-bar,