这行代码给了我红线错误。我不知道我做错了什么。当我输入"新的FirebaseRecyclerAdapter"时,我会注意到一件事。它给了我覆盖方法2而不是1,这是onPopulateViewHolder在Youtube上的TVAC视频教程中看到的缺失。
这是代码:
public class ViewListTutor extends AppCompatActivity {
private RecyclerView mListTutor;
private DatabaseReference mlistDatabase;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_list_tutor);
mlistDatabase = FirebaseDatabase.getInstance().getReference().child("Users").child("Tutors");
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mListTutor = (RecyclerView) findViewById(R.id.tutor_list);
mListTutor.setHasFixedSize(true);
mListTutor.setLayoutManager(new LinearLayoutManager(this));
}
@Override
protected void onStart() {
super.onStart();
FirebaseRecyclerAdapter<ListTutorItem, TutorViewHolder> FirebaseRecyclerAdapter = new FirebaseRecyclerAdapter<ListTutorItem, TutorViewHolder>(
ListTutorItem.class,
R.layout.tutor_row,
TutorViewHolder.class,
mlistDatabase
) {
@Override
protected void onBindViewHolder(TutorViewHolder holder, int position, ListTutorItem model) {
}
@Override
public TutorViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return null;
}
};
}
图像:
我对UI Firebase数据库的依赖:
compile 'com.firebaseui:firebase-ui-database:0.4.0'