Witam,
(pisze na laptopie nie obslugujacym polskich znakow)
Pisze aplikacje ktora m.in. ma czytac osoby ktore obserwuje uzytkownik. Calosc jest podpieta pod Firebase. Niestety w moim ListView nie pojawiaja sie dane pobierane z Database. Kiedy wchodze w aktywnosc w ktorej mam obejrzec osoby ktore obserwuje, niestety widze tylko biala przestrzen i nic poza tym. Logcat nic nie pokazuje. W zwiazku z tym nie wiem czy wina lezy w wyciaganiu danych z FirebaseDatabase czy w przenoszeniu ich adapterem na ListView. Prosze o pomoc:)
FollowingFragment.java
public class FollowingFragment extends AppCompatActivity{
private ListView mListView;
TextView username;
CircleImageView profilePhoto;
private Context mContext;
List<FollowingRow> followingList;
DatabaseReference databaseFollowing;
@Nullable
public void onCreateView(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_following);
mContext = this;
mListView = (ListView) findViewById(R.id.listView1);
databaseFollowing = FirebaseDatabase.getInstance().getReference("following").child("user_id");
followingList = new ArrayList<>();
getIncomingIntent();
databaseFollowing.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
followingList.clear();
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
FollowingRow following = postSnapshot.getValue(FollowingRow.class);
followingList.add(following);
}
FollowingList adapter = new FollowingList(FollowingFragment.this, followingList);
mListView.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
private void getIncomingIntent(){
Intent intent = getIntent();
}
}
FollowingList.java
public class FollowingList extends ArrayAdapter<FollowingRow> {
private Activity context;
List<FollowingRow> followingList;
public FollowingList(Activity context, List<FollowingRow> followingList) {
super(context, R.layout.layout_followrow, followingList);
this.context = context;
this.followingList = followingList;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.layout_followrow, null, true);
TextView username = (TextView) listViewItem.findViewById(R.id.following_username2);
// ImageView followingPhoto = (ImageView) listViewItem.findViewById(R.id.following_profile_image2);
FollowingRow fRow = followingList.get(position);
username.setText(fRow.getfName());
return listViewItem;
}
}
FollowingRow.java
public class FollowingRow {
//private String comment;
private String user_id;
private String fName;
// private List<Like> likes;
// private String date_created;
public FollowingRow() {
}
public FollowingRow( String user_id, String fName) {
this.user_id = user_id;
this.fName = fName;
}
public String getUser_id() {
return user_id;
}
public String getfName() {
return fName;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
}
@Override
public String toString() {
return "FollowingRow{" +
" user_id='" + user_id + '\'' + '}';
}
}