我在android中使用firebase。我面临的问题是数据存储在我的数据库中,但我无法显示它们。这是我的代码:
final FirebaseRecyclerOptions<Blog> options =
new FirebaseRecyclerOptions.Builder<Blog>()
.setQuery(databaseReference, Blog.class)
.build();
final FirebaseRecyclerAdapter<Blog, BlogViewHolder>
firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Blog, BlogViewHolder>(options) {
@Override
public BlogViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.blog_row, parent, false);
return new BlogViewHolder(view);
}
@Override
protected void onBindViewHolder(BlogViewHolder holder, int position, Blog model) {
holder.setDesc(model.getDescription());
holder.setTitle(model.getTitle());
Log.w("ok","ok");
}
我如何在我看来展示它们。
答案 0 :(得分:0)
你可以试试这个......
recyclerView = (RecyclerView)findViewById(R.id.mRecyclerView);
recyclerView.setHasFixedSize(true);
LinearLayoutManager llm = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(llm);