Created
December 27, 2016 17:23
-
-
Save budioktaviyan/9aa861f813fd5af4f047f0ba43f5c0ce to your computer and use it in GitHub Desktop.
Home Fragment Class (Cont'd)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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