2 回答
TA贡献1900条经验 获得超5个赞
您可以在适配器内执行此操作
// make this function inside your adapter
protected void populateView(View v, ArrayList<TravelDetails> models, final int position) {
Button delete=(Button)v.findViewById(R.id.button_accept);
final TextView z=(TextView)v.findViewById(R.id.dropoff);
final TextView text=(TextView)v.findViewById(R.id.txref);
text.setText(model.getTxt_Ref());
z.setText(model.getDropoffspot());
delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// code to delete from firebase
models.remove(position); // delete from adapter array list
notifyDataSetChanged(); // refresh adapter
}
}
}
TA贡献1886条经验 获得超2个赞
我找到了如何解决我的问题。我只是将其添加到单击方法的删除按钮中。
public void onClick(View v) { DatabaseReference item=adapter.getRef(position) ; item.removeValue();
} }) ;
添加回答
举报