Skip to content

Instantly share code, notes, and snippets.

@budioktaviyan
Created December 27, 2016 17:23
Show Gist options
  • Save budioktaviyan/9aa861f813fd5af4f047f0ba43f5c0ce to your computer and use it in GitHub Desktop.
Save budioktaviyan/9aa861f813fd5af4f047f0ba43f5c0ce to your computer and use it in GitHub Desktop.
Home Fragment Class (Cont'd)
public class HomeFragment extends Fragment {
@Override
public void onActivityCreated(@Nullable final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Prepare mock object into list of items
final List<String> items = new ArrayList<>();
items.add("Opsi Satu");
items.add("Opsi Dua");
items.add("Opsi Tiga");
items.add("Opsi Empat");
items.add("Opsi Lima");
items.add("Opsi Enam");
items.add("Opsi Tujuh");
items.add("Opsi Delapan");
items.add("Opsi Sembilan");
items.add("Opsi Sepuluh");
final RecyclerView recyclerView = (RecyclerView) getActivity().findViewById(R.id.rv_home);
final LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
final HomeAdapter homeAdapter = new HomeAdapter(items);
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.smoothScrollToPosition(recyclerView.getBottom());
recyclerView.setAdapter(homeAdapter);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment