//回調接口ide
public interface BottomCallBackInterface { public interface OnBottomClickListener { void onBottomClick(View v, int position); } }
//適配器中引用該方法this
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中實現該接口xml
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){ } } }