Created
May 7, 2017 16:36
-
-
Save andersonkxiass/425407dabcd07f5aabdfee4ea5bc30c7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 RecyclerViewWithClickVM { | |
| private RecyclerView.LayoutManager layoutManager; | |
| private List<Object> objectList = new ArrayList<>(); | |
| @BindingAdapter("adapter") | |
| public static void bindAdapter(RecyclerView recyclerView, List<Object> objectList) { | |
| YourAdapter adapter = new YourAdapter(objectList); | |
| recyclerView.setAdapter(adapter); | |
| } | |
| public RecyclerView.LayoutManager getLayoutManager() { | |
| return layoutManager; | |
| } | |
| public void setLayoutManager(RecyclerView.LayoutManager layoutManager) { | |
| this.layoutManager = layoutManager; | |
| } | |
| public void onItemClicked(RecyclerView recyclerView, int position, View v) { | |
| Toast.makeText(v.getContext(), "position = " + position, Toast.LENGTH_SHORT).show(); | |
| } | |
| public List<Object> getObjectList() { | |
| return objectList; | |
| } | |
| public void setObjectList(List<Object> objectList) { | |
| this.objectList = objectList; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment