无法从 PopulateViewHolder 内部访问 RecyclerAdapter

Cant access RecyclerAdapter from inside PopulateViewHolder

我有这个

        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 需要声明为最终的。当我声明它为 final 时,它说,mAdapter 从未被初始化。 请解答

您正在尝试访问您自己。 mAdapter == this.

您可以只使用 this 或像这样省略它:

String fullName = this.getRef(position).getKey();

String fullName = getRef(position).getKey();