我有dataSnapshot,它正在ListView中显示信息,但我想反转显示。我希望最后一个帖子位于ListView的顶部。
databaseReference = FirebaseDatabase.getInstance().getReference("Trips");
listViewTrips = (ListView) findViewById(R.id.listViewTrips);
tripList = new ArrayList<>();
}
@Override
protected void onStart() {
super.onStart();
databaseReference.addValueEventListener(new ValueEventListener() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
tripList.clear();
for(DataSnapshot tripSnapshot : dataSnapshot.getChildren()){
Artist artist = tripSnapshot.getValue(Artist.class);
tripList.add(artist);
}
TripList adapter = new TripList(postHistory.this, tripList);
listViewTrips.setAdapter(adapter);
}
我希望页面顶部发布最后一次旅行。