Firebase Firestore UI为了使用片段中的RecyclerView+CardView组合显示集合,我的项目使用了,我使用了FirestoreUI它自己提供的适配器。
FirestoreRecyclerAdapter
但是,我无法onItemClickListener在显示的每张卡上都设置一个。
FirestoreRecyclerAdapter adapter = new FirestoreRecyclerAdapter<Record, recordViewHolder>(options) {
@Override
public void onDataChanged() {
progressBar.setVisibility(View.GONE);
}
@Override
public void onError(@NonNull FirebaseFirestoreException e) {
Log.e(TAG, "onError: ", e);
}
@Override
protected void onBindViewHolder(@NonNull recordViewHolder holder, int position, @NonNull Record record) {
holder.date.setText(String.valueOf(record.getFullDate()));
holder.qty.setText(String.valueOf(record.getQty()));
holder.rate.setText(String.valueOf(record.getRate()));
holder.total.setText(String.valueOf(record.getTotal()));
holder.milkType.setText(String.valueOf(record.getMilkType()));
}
@NonNull
@Override
public recordViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(getContext());
View view = inflater.inflate(R.layout.record_logs_card, parent, false);
return new recordViewHolder(view, mListener);
}
};
这样的设置会onItemClickListener导致语法错误。
onItemClickListener
当适配器本身是变量而不是的扩展类时,我该如何实际设置RecyclerAdapter
并传递位置以提取准确的卡?
收到一只叮咚
相关分类