I have a FragmentActivity that has the values I needed to be used in a Fragment.
This is the way I do it, but I have no idea on how to access the getter in the FragmentActivity.
ItemDetailActivity
public class ItemDetailActivity extends FragmentActivity implements ActionBar.TabListener {
public String getItem_id() {
return item_id;
}
public String getUser_id() {
return user_id;
}
...
}
ItemPhotosFragment
public class ItemPhotosFragment extends Fragment {
public ItemPhotosFragment() {
user_id = getActivity().getUser_id();
}
}
As you can see in the FragmentActivity, I'm implementing TabListener. So I'm want to pass the values to all tabs (fragments).
How do I do this? Is accessing from getActivity a best practice because I saw some of the solutions here suggesting it.