On Thu, Nov 26, 2015 at 12:35 AM, Vinayak Mestri <[email protected]
> wrote:

> I want to do like above code i.e student is reference variable so if i
> change any values of student arraylist will reflect to actual object in
> activity


1 - Look at the documentation for Fragment which shows the static
constructor pattern that is typically used to construct a fragment with
parameters.
http://developer.android.com/reference/android/app/Fragment.html
Your model object would implement the Parcelable interface to be passed
along as data.

2 - You can then let the Activity know when changes are made via callbacks:
http://developer.android.com/guide/components/fragments.html#CommunicatingWithActivity

You generally don't want the exact same data object in the activity and
fragment. If you really really do, you could alternative expose it as a
public method in the Activity then instead of passing it to the fragment,
access your activity in the fragment (onAttach or onActivityCreated or
something) and get the list data, which would be the actual list both
objects would share.

-------------------------------------------------------------------------------------------------
TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
transit tracking app for Android-powered devices

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/CANCScgj%2BiWtXnxK934KmdBO6HWR-RUX5gurN7OyPsAOk_4E%3Dnw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to