我是Android的初学者。我想使用回收者视图位置将数据保存到Firebase。例如,我是“ A”用户,当我单击回收者视图项(它是“ B”用户)时,我得到“ B”的用户UID并保存“ A”用户的数据,例如“ kullanici”,“ sifre”(参见示例):
final RecyclerView recyclerView2 = findViewById(R.id.recyclerView);
recyclerView2.addOnItemTouchListener(
new RecyclerItemClickListener(getApplicationContext(), recyclerView2 ,new RecyclerItemClickListener.OnItemClickListener() {
@Override public void onItemClick(View view, int position) {
Toast.makeText(getApplicationContext(),"Long Click"+ epostaList.get(position),Toast.LENGTH_SHORT).show();
String value = (String) recyclerView2.getVerticalScrollbarPosition(position);
databaseReference = FirebaseDatabase.getInstance().getReference().child("users");
databaseReference.child(resgisterpage.cinsiyyet.toString()).child("connections").child("yeps").child(resgisterpage.userId).setValue(true);
// FirebaseUser currentFirebaseUser = FirebaseAuth.getInstance().getCurrentUser() ;
// Toast.makeText(context, "" + currentFirebaseUser.getUid(), Toast.LENGTH_SHORT).show();
//Toast.makeText(context,"Kayıt Başarılı.",Toast.LENGTH_LONG).show();
}
@Override public void onLongItemClick(View view, int position) {
// do whatever
}
})
);