Not quite as simple as it would seem. You can't use onCreate()
method because it is called before onViewCreate()
. However, you can used onViewCreate
, because you inflate your view: hence you have access to it:
1 2 3 4 5 6 7 8 9 10 11 |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_stops_list, container, false); ListView stops = (ListView) rootView.findViewById(R.id.list_of_stops); if(stops != null) { stops.setAdapter(new ListAdapter(getActivity(), 0, Settings.cTour.getStops())); } else { Log.e(TAG, "list_of_stops not found"); } return rootView; } |