github链接: https://github.com/CymChad/BaseRecyclerViewAdapterHelper
作者简书: http://www.jianshu.com/u/f958e66439f0
Item子控件的点击事件
首先在adapter的convert方法里面通过viewHolder.addOnClickListener绑定一下的控件id
@Override
protected void convert(BaseViewHolder viewHolder, Status item) {
viewHolder.setText(R.id.name, item.getName)
.addOnClickListener(R.id.name)
}
然后再设置
adapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
/*为了区分点击了哪一个item子控件*/
switch (view.getId()) {
case R.id.textView1:
LogUtils.d(TAG + "____1", "____" + position);
break;
case R.id.textView2:
LogUtils.d(TAG + "____2", "____" + position);
break;
default: {
break;
}
}
}});
类似贴吧加载功能(实际也就是重新请求一次服务器),需要重新设置数据。需要判断本地帖子回复数量和服务器帖子回复数量是否一致
if (adapter.getData().size() < Bean.getData().size()) {
adapter.setNewData(Bean.getData());
}