Firebase Data Desc Sorting in Android

前端 未结 15 2179
醉话见心
醉话见心 2020-11-22 07:51

I am storing data in Firebase storage.

Object Comment with attribute timestamp. When I push data from device to Firebase I\'m populating

15条回答
  •  不思量自难忘°
    2020-11-22 08:13

    I have solved problem by extending FirebaseListAdapter and overriding getItem method:

    public abstract class ReverseFirebaseListAdapter extends FirebaseListAdapter  {
    
    public ReverseFirebaseListAdapter(Activity activity, Class modelClass, int modelLayout, Query ref) {
        super(activity, modelClass, modelLayout, ref);
    }
    
    public ReverseFirebaseListAdapter(Activity activity, Class modelClass, int modelLayout, DatabaseReference ref) {
        super(activity, modelClass, modelLayout, ref);
    }
    
    @Override
    public T getItem(int position) {
      return super.getItem(getCount() - (position + 1));
    }
    

    }

提交回复
热议问题