/**
* 删除的回调接口
*/
//创建接口
public interface OnDeleteListener{
void delete(Node node, int position);
}
//声明接口对象
private OnDeleteListener mOnDeleteListener;
//设置监听器,实例化接口
public void setOnDeleteListener(OnDeleteListener onDeleteListener){
mOnDeleteListener = onDeleteListener;
}
//删除按钮的接口回调
viewHolder.mDelete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mOnDeleteListener.delete(node, position);
}
});
//侧滑删除按钮点击事件
mAdapter.setOnDeleteListener(new SimpleTreeAdapter.OnDeleteListener() {
@Override
public void delete(Node node, int position) {
}
});
转载自原文链接, 如需删除请联系管理员。
原文链接:Android回调接口的写法,转载请注明来源!