我想获得如下图所示的键值。我正在使用 firebase 回收器适配器来检索来自键的数据,但现在我想获取键值。
现在我正在使用的代码仅检索数据 this 。
private void setFirebaseRecyclerAdapterKarangan() {
firebaseRecyclerOptionsKarangan = new FirebaseRecyclerOptions.Builder<UserAlphaKaranganClick>()
.setQuery(databaseReference.child("userAlphaKaranganClick").child(userUid), UserAlphaKaranganClick.class)
.build();
firebaseRecyclerAdapterKarangan = new FirebaseRecyclerAdapter<UserAlphaKaranganClick, UserAlphaActivityLogKaranganViewHolder>(firebaseRecyclerOptionsKarangan) {
@Override
protected void onBindViewHolder(@NonNull final UserAlphaActivityLogKaranganViewHolder holder, final int position, @NonNull final UserAlphaKaranganClick model) {
//We need to convert to become string since it is from long
holder.getTextViewClick().setText(String.valueOf(model.getClick()));
holder.getTextViewLike().setText(String.valueOf(model.getLike()));
}
@NonNull
@Override
public UserAlphaActivityLogKaranganViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.user_alpha_activity_log_karangan_item, viewGroup, false);
return new UserAlphaActivityLogKaranganViewHolder(view);
}
};
//Display
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
linearLayoutManager.setStackFromEnd(true);
linearLayoutManager.setReverseLayout(true);
firebaseRecyclerAdapterKarangan.startListening();
recyclerView2.setAdapter(firebaseRecyclerAdapterKarangan);
recyclerView2.setLayoutManager(linearLayoutManager);
}
爪哇安卓火力基地
鸿蒙传说
相关分类