万能适配器单布局 加 条目子控件点击事件

sheQuAdapter = new SheQuAdapter(R.layout.shequ_item, resultList);

 

 sheQuAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
        @Override
        public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {

            switch (view.getId()) {
                case R.id.shequ_fayan:

                    int is_essence = resultList.get(position).getIs_essence();
                    is_essence++;
                    resultList.get(position).setIs_essence(is_essence);
                    sheQuAdapter.notifyDataSetChanged();
                    ImageView img = view.findViewById(R.id.shequ_fayan);
                    img.setBackgroundResource(R.drawable.service_online);
                    window.showAtLocation(getActivity().findViewById(R.id.shequ), Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM, 0, 0);

                    break;
                case R.id.shequ_dianzan:
                    int iscollect = resultList.get(position).getIscollect();
                    iscollect++;
                    resultList.get(position).setIscollect(iscollect);
                    sheQuAdapter.notifyDataSetChanged();
                    ImageView img2 = view.findViewById(R.id.shequ_dianzan);
                    img2.setBackgroundResource(R.drawable.find_thumbs_up_true);

                    break;
                case R.id.shequ_bixin:
                    int isgive = resultList.get(position).getIsgive();
                    isgive++;
                    resultList.get(position).setIsgive(isgive);
                    sheQuAdapter.notifyDataSetChanged();
                    ImageView img1 = view.findViewById(R.id.shequ_bixin);
                    img1.setBackgroundResource(R.drawable.find_like_img);

                    break;
                case R.id.dashang:

                    if (AlipayUtil.hasInstalledAlipayClient(getActivity())){
                        AlipayUtil.startAlipayClient(getActivity(),"FKX051943BERN1XTWGS664"); // 第二步获取到的字符串
                    }else{
                        Toast.makeText(getActivity(), "未检测到支付宝,无法实现打赏功能", Toast.LENGTH_SHORT);
                    }
                    break;
            }
        }
    });

}

 

 

 

public class SheQuAdapter  extends BaseQuickAdapter<SheQu.ResultListBean, BaseViewHolder> {


    public SheQuAdapter(int layoutResId, @Nullable List<SheQu.ResultListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SheQu.ResultListBean item) {

        Glide.with(mContext).load(item.getIcon()).apply(RequestOptions.bitmapTransform(new CircleCrop())).into((ImageView) helper.getView(R.id.shequ_dainji_img));
        helper.setText(R.id.shequ_dianji_text, item.getNickname())
                .setText(R.id.shequ_text2, item.getDescription())
             .setText(R.id.shequ_text3, item.getCrtime())
                .addOnClickListener(R.id.shequ_fayan)
                .addOnClickListener(R.id.shequ_dianzan)
                .addOnClickListener(R.id.shequ_bixin)
                .addOnClickListener(R.id.dashang)
               .setText(R.id.fayan_text,String.valueOf(item.getIs_essence()))
                .setText(R.id.dianzan_text,String.valueOf(item.getIscollect()))
                .setText(R.id.bixin_text,String.valueOf(item.getIsgive()));








    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值