使用recyclerview Firebase上的按钮更新和删除

时间:2019-10-07 19:13:20

标签: android firebase android-recyclerview google-cloud-firestore

每位开发人员都好, 我正在一个名为e-School的项目中工作,我在使用Firebase适配器和原始操作时遇到了麻烦,我在recyclerview中有一个cardview,在该cardview上有一个“ update”和“ delete”按钮,我想触发{{1 }}和Button edit_t的图片链接位于Check Image,而Firebase结构也位于db image,但是我无法使按钮起作用需要帮助! 代码如下

// TeacherViewHolder.java

Button delete_t

// TeachersAdapter.java

public class TeachersViewHolder extends RecyclerView.ViewHolder{
public CircleImageView teacherImage;
public TextView teacherName,teacherDesignation;

public TeachersViewHolder(@NonNull View itemView) {
    super(itemView);
    teacherImage = itemView.findViewById(R.id.image_teacher);
    teacherName =  itemView.findViewById(R.id.teacher_nome);
    teacherDesignation = itemView.findViewById(R.id.teacher_designation);
}}

1 个答案:

答案 0 :(得分:1)

所以伙计们,我试图摆脱这一点,我尝试编写了大量代码,最后得到了解决方案,这就是解决方案..... TeachersAdapter.java中的onBindViewHolder中有几行代码要编写,以使我们的按钮正常工作,代码如下。...下一个活动的图像链接也位于此处{ {3}}和此处clicking on update button in recyclerview

TeachersAdapter.java

       holder.edit_t.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent goUpdateTeacher = new Intent(holder.edit_t.getContext(), UpdateTeacher.class);
            goUpdateTeacher.putExtra("photourl", sTeachers.getPhotourl());
            goUpdateTeacher.putExtra("teacherName", sTeachers.getName());
            goUpdateTeacher.putExtra("teacherDesignation", sTeachers.getQualification());

            holder.edit_t.getContext().startActivity(goUpdateTeacher);
        }
    });