我的firebase real time database
中的孩子列表正在检索firebase ui recycler view
。 model
参数从我的所有视图中获取字符串列表。但我想要的是从单击的特定项中检索单个字符串。我该如何绕过这个?
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);
}
答案 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
}
});