transfer List from activity to fragment in Android

I have an activity:

public List<Steps> steps;
Recipe recipe;
protected void onCreate(Bundle savedInstanceState) {
steps = recipe.getRecipeSteps();

int len1 = steps.size();
Log.i(TAG, "Steps length=" + len1);

public List<Steps> getMyData() {
return steps;

and a fragment

public class FragmentStepTitle extends Fragment {
// Whether the app has two panel( tablet ) or one panel( phone ).
//private boolean hasTwoPanel = false;

public View onCreateView(LayoutInflater inflater, @ ViewGroup container, @ Bundle savedInstanceState) {
//receive info from detail

DetailActivity activity = (DetailActivity) getActivity();
List<Steps> myDataFromActivity = activity.getMyData();
Log.i("Fragment",myDataFromActivity.get(0).getShor tDescription());

return ret;

The error caused is:
Attempt to invoke interface method ‘java.lang.Object java.util.List.get(int)’ on a null object reference
at com.example.ionutb.baking.ui.FragmentStepTitle.onC reateView

Why I don-t see the List value??

Show Accepted Answer

Guest Quick Reply (No URL, BBcode or HTML)

Last post by qdooley
3 hours ago
Last post by jerde.wendell
3 hours ago
Last post by karelle71
3 hours ago
Last post by josue28
4 hours ago
Last post by bettye.kutch
1 hour ago
Last post by jarred53
1 hour ago
Last post by halvorson.kolby
1 hour ago