我正在尝试反转显示

时间:2019-07-16 20:09:46

标签: java firebase-realtime-database

我有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);


        }

我希望页面顶部发布最后一次旅行。

0 个答案:

没有答案