获取单个firebase回收器视图项android的String

时间:2018-05-25 01:22:55

标签: android firebase firebase-realtime-database android-recyclerview firebaseui

我的firebase real time database中的孩子列表正在检索firebase ui recycler viewmodel参数从我的所有视图中获取字符串列表。但我想要的是从单击的特定项中检索单个字符串。我该如何绕过这个?

FirebaseRecyclerAdapter<Sermon, SermonViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<Sermon, SermonViewHolder>(Sermon.class, R.layout.item_view, SermonViewHolder.class, mDatabase) {
            @Override
            protected void populateViewHolder(SermonViewHolder viewHolder, Sermon model, int position) {

                final String audioLink = model.getAudioLink(); 
// This retrieves data from all the data model at the same. I need string for the particular item clicked.

            }
        };
        mRecyclerView.setAdapter(firebaseRecyclerAdapter);
    }

1 个答案:

答案 0 :(得分:1)

您可以尝试使用setOnClickListener

中的populateViewHolder方法
 viewHolder.view.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                     //Retrieve your string from model object using position variable
                    //which is an argument in `populateViewHolder` method
                    }
                  });