Closed dagostinelli closed 6 years ago
I'm trying to use the lib and my list view is only displaying the first element.
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.simple_recyclerview); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(this)); RxDataSource<SimpleViewModel> rxDataSource = new RxDataSource<>(generateSimpleList()); rxDataSource .<MyLayoutBinding>bindRecyclerView(recyclerView, R.layout.my_layout) .subscribe(viewHolder -> { MyLayoutBinding b = viewHolder.getViewDataBinding(); SimpleViewModel x = viewHolder.getItem(); b.simpleTextView.setText(x); });
The list is of 100 elements
private List<SimpleViewModel> generateSimpleList() { List<SimpleViewModel> simpleViewModelList = new ArrayList<>(); for (int i = 0; i < 100; i++) { simpleViewModelList.add(new SimpleViewModel(String.format(Locale.US, "This is item %d", i))); } return simpleViewModelList; }
SimpleViewModel
public class SimpleViewModel { private String simpleText; public SimpleViewModel(@NonNull final String simpleText) { Check.requireNonNull(simpleText); setSimpleText(simpleText); } @NonNull public String getSimpleText() { return simpleText; } public void setSimpleText(@NonNull final String simpleText) { Check.requireNonNull(simpleText); this.simpleText = simpleText; } }
This was the solution. It had nothing to do with this lib.
I'm trying to use the lib and my list view is only displaying the first element.
The list is of 100 elements
SimpleViewModel