publicclassMyHolderextendsKRecyclerViewHolder {
privateTextView titleLabel, descLabel;
publicMyHolder(ViewitemView) {
super(itemView);
titleLabel = (TextView) itemView.findViewById(R.id.titleLabel);
descLabel = (TextView) itemView.findViewById(R.id.descLabel);
}
@OverrideprotectedvoidsetSelected(@NonNullContextcontext, booleanselected) {
super.setSelected(context, selected);
// This method is called whenever the holder is selected/unselected.if (selected) {
// Selected
} else {
// Unselected
}
}
@OverrideprotectedvoidsetData(@NonNullContextcontext, @NonNullObjectitemObject) {
super.setData(context, itemObject);
// This method is called automatically by the adapter.// override this method and set your data here...// Check the type of itemObjectif (itemObject instanceofMyObject) {
MyObject myObject = (MyObject)itemObject;
titleLabel.setText(myObject.title);
descLabel.setText(myObject.description);
}
}
}
adapter.allowsSingleSelection =true; // Enables single selection
adapter.allowsMultipleSelection =true; // Enables multiple selection
adapter.deselectItemOnClickIfSelected =true; // Deselects the item if already selected.
adapter.getSelectedIndexes(); // Get list of selected item positions
Rx is a generic abstraction of computation expressed through Observable<Element> interface, which lets you broadcast and subscribe to values and other events from an Observable stream.