//回调接口
public interface BottomCallBackInterface { public interface OnBottomClickListener { void onBottomClick(View v, int position); } }
//适配器中引用该方法
private OnBottomClickListener mListener; public WaitTakingAdapter(Context context, List<OrderInfo> dataList, OnBottomClickListener listener) { if(context == null){ return; } this.mContext = context; this.dataList = dataList; mListener = listener; } //响应回调事件 holder.layoutDetail.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { if(mListener != null){ mListener.onBottomClick(arg0, position); } } });
在Activity中实现该接口
implements BottomCallBackInterface
mAdapter = new WaitTakingAdapter(mContext, sortList, new OnBottomClickListener() { @Override public void onBottomClick(View v, int position) { OrderInfo info = sortList.get(position); if(v.getId() == R.id.item_order_wait_layout_check){ } } }
时间: 2024-10-28 16:53:52