Skip to content

Instantly share code, notes, and snippets.

@chrisblakely01
chrisblakely01 / recyclerViewFragment.kt
Created March 20, 2018 20:05
Example of how to add a recyclerView to a fragment in kotlin
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_city_list, container, false)
// Replace 'android.R.id.list' with the 'id' of your RecyclerView
mRecyclerView = (RecyclerView) view.findViewById(android.R.id.list);
mLayoutManager = new LinearLayoutManager(this.getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
mAdapter = new RecyclerAdapter(getNames());