Anzeige

RecyclerView Firebase UI


#1
Hey Leute,
ich habe versucht ein Messenger zu programmieren wo man bei einen Punk talle Benutzer die die App hat sehen kann. Der Code dazu sieht so aus:
Java:
public class AllUserActivity extends AppCompatActivity {


Toolbar mToolbar;
RecyclerView recyclerView;
private DatabaseReference mUserDatabse;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_user);


mToolbar = (Toolbar) findViewById(R.id.usersappbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("Alle Benutzer");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

mUserDatabse = FirebaseDatabase.getInstance().getReference().child("Users");

recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));

}

@Override
protected void onStart() {
super.onStart();

FirebaseRecyclerAdapter<User, UsersViewHolder> firebaseRecyclerAdapter = new FirebaseRecyclerAdapter<User, UsersViewHolder>(User.class, R.layout.users_single_layout, UsersViewHolder.class, mUserDatabse) {
@Override
protected void populateViewHolder(UsersViewHolder viewHolder, User model, int position) {
viewHolder.setName(model.getName());
}
};

firebaseRecyclerAdapter.startListening();
recyclerView.setAdapter(firebaseRecyclerAdapter);
User Activity:

Java:
public class User {

public String name;
public String Image;
public String status;

public User(){

}

public User(String name, String image, String status) {
this.name = name;
Image = image;
this.status = status;
}

public String getName() {

return name;
}

public void setName(String name) {
this.name = name;
}

public String getImage() {
return Image;
}

public void setImage(String image) {
Image = image;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}
}
}

public static class UsersViewHolder extends RecyclerView.ViewHolder {

View mView;

public UsersViewHolder(@NonNull View itemView) {
super(itemView);

mView = itemView;
}

public void setName(String name){

TextView userNameView = (TextView) mView.findViewById(R.id.username_tv);
userNameView.setText(name);
}


}

}
Mein problem ist das überhapt kein Benutzer im RecyclerView angezeigt wird. KAnn mir da vllt jemand helfen?
 
Anzeige