I've set up a fragment inside my activity, but I'm wondering how I can pass data from the activity into the fragment?
For example, this is my code:
    public class MyFragment extends Fragment 
{   
    private MyData _myData;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
    {   
        // Inflate the layout for this fragment 
        return inflater.inflate(R.layout.custom_fragment, container, false);
        MyActivity activity = (MyActivity) getActivity(); // Unreachable code error here
        _myData = activity.getMyData();
    }
}
I need to be able to access the contents of the MyData object in the fragment. But when I try this code above, I get an "Unreachable Code" error, even though getMyData() is a public method in the MyActivity class.
 
     
     
     
    