将Firebase Recycler适配器从填充视图支架转换为onCreate和onBind视图支架

时间:2019-07-26 21:38:30

标签: java android firebase recycler-adapter

我刚刚更新了我的Android库(包括Firebase),现在看来与Firebase Recyler Adapter的实现相关的更改有所变化。代替PopulateViewHolder,现在要实现2套新功能,即onBindViewHolder和onCreateViewHolder。您能帮我怎么做吗?

我确实浏览过Google文档,但无法在我的情况下实现它。

            private void loadListDiagnostic(String categoryId) {
            adapter = new FirebaseRecyclerAdapter<Doctor, DoctorViewHolder>(Doctor.class,
            R.layout.doctors_item,
            DoctorViewHolder.class,
            doctorList.orderByChild("menuId").equalTo(categoryId)
            ) {
            @Override
            protected void populateViewHolder(DoctorViewHolder viewHolder, Doctor model, int position) {
            viewHolder.department_name.setText(model.getDepartment());
            Picasso.with(getBaseContext()).load(model.getImage())
                    .into(viewHolder.department_image);

            final Doctor local = model;
            viewHolder.setItemClickListener(new ItemClickListener() {
                @Override
                public void onClick(View view, int position, boolean isLongClick) {
                    //Start new activity
                    Toast.makeText(DoctorList.this, "Coming Soon !!", Toast.LENGTH_SHORT).show();

                }
            }

        }
    }

}

0 个答案:

没有答案