我有这个
FirebaseRecyclerAdapter mAdapter = new FirebaseRecyclerAdapter<ChatList, ChatHolder>(ChatList.class, R.layout.chatlistrow, ChatHolder.class, chatRef) {
@Override
public void populateViewHolder(ChatHolder chatViewHolder, final ChatList chatList, final int position) {
//try catch block to catch events of no posts, it will most likely return a null error, so im catching it, else
//find its exception and catch it
String fullName = mAdapter.getRef(position).getKey();
chatViewHolder.setName(fullName);
但该行
String fullName = mAdapter.getRef(position).getKey();
说mAdapter
需要宣布为最终版。当我宣布它是最终的时,它说,mAdapter
从未被初始化。
解决方案,请
答案 0 :(得分:2)
您正试图访问自己。 mAdapter
== this
。
您可以使用this
或省略它:
String fullName = this.getRef(position).getKey();
或
String fullName = getRef(position).getKey();