Support Any Type of items in recyclerview with no pain
compile 'ir.coderz.coreadapter:Core-Adapter:0.1.9@aar'
public class TextHolder extends RecyclerView.ViewHolder {
private TextView textView;
public TextHolder(View itemView) {
super(itemView);
textView = (TextView) itemView.findViewById(R.id.text);
}
public TextView getTextView() {
return textView;
}
}
public class TextItem implements CoreItem<TextHolder, String> {
@Override
public void bind(TextHolder textHolder) {
// This is the onbind method used to be inside adapter
textHolder.getTextView().setText(textHolder.getAdapterPosition() + "");
}
@Override
public int getLayout() {
// You must return the related layout
return R.layout.text_item;
}
@Override
public String getData() {
// you might need the data! so return it here :)
return textHolder.getAdapterPosition() + "";
}
}
CoreAdapter coreAdapter = new CoreAdapter();
recycler.setAdapter(coreAdapter);
coreAdapter.putViewType(R.layout.YOUR_LAYOUT, YOUR_HOLDER.class);
coreAdapter.addItem(new TextItem());