我有这个
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
从未初始化。解决方案请
您正在尝试访问自己。 mAdapter
== this
。
您只能使用this
或省略以下内容:
String fullName = this.getRef(position).getKey();
或
String fullName = getRef(position).getKey();