Recyclerview Activity To Fragment
Im following a tutorial in on recyclerview found here http://javatechig.com/android/android-recyclerview-example I have modified it to suit me needs, except for one thing, the Main
Solution 1:
setContentView()
is only in an Activity
. You need to inflate the layout in the onCreateView()
method that you will override.
publicViewonCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_recyclerview,
container, false);
}
See here for more info on that - super.onCreateView in Fragments
For findViewById
you can do one of 2 things -
You can write getActivity().findViewById()
or in the onCreateView
method you can say:
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Viewview= inflater.inflate(R.layout.fragment_recyclerview,
container, false)
view.findViewById....
return;
}
Post a Comment for "Recyclerview Activity To Fragment"