compile'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.6.1'
一个非常不错的万能适配器:
使用:
首先让javaBean实现implements MultiItemEntity这个接口,
@Override
public intgetItemType() {
//根据自己的逻辑,returnitemType,方便起见,比如这里return 0,1,2,3
}
则在adapter里面:
public classMyAdapter extends BaseMultiItemQuickAdapter<JavaBean,BaseViewHolder>{
publicRecyclerCircleAdapter(List dataBeans,Context context) {
super(dataBeans);
this.context= context;
this.dataBeans= dataBeans;
addItemType(1,R.layout.item1);
addItemType(2,R.layout.item2);
addItemType(3,R.layout.item3);
addItemType(4,R.layout.item4);
}
@Override
protected voidconvert(finalBaseViewHolder baseViewHolder, finalBean_shuoshuo.DataBean dataBean) {
baseViewHolder.getView(R.id.content).setFocusable(false);
baseViewHolder
.setText(R.id.username,dataBean.getNickname())
.setText(R.id.tv_time,"")
.setText(R.id.tv_pinglun_num,"")
.setText(R.id.tv_dianzan_num,dataBean.getAgrees() +"");
baseViewHolder.setOnClickListener(R.id.XXX, newView.OnClickListener() {
@Override
public voidonClick(View view) {
}
});
}