排序从Firebase获取的数据,我想排序以获取最新数据(顶部)

时间:2020-02-05 03:57:12

标签: android firebase-realtime-database firebaseui

public void showList(){
    FirebaseRecyclerOptions options =
            new FirebaseRecyclerOptions.Builder<Model>()
                    .setQuery(reference,Model.class)
                    .build();
    adapter = new FirebaseRecyclerAdapter<Model, ViewHolder>(options) {
        @Override
        protected void onBindViewHolder(@NonNull ViewHolder viewHolder, int i, @NonNull final Model model) {
            ///What happen to data obtainied from fire base

            viewHolder.txtViewDescription.setText(model.getmName());

            Picasso.with(MainActivity.this)
                    .load(model.getmImageUri())
                    .fit()
                    .centerCrop()
                    .into(viewHolder.tvImageView);

            viewHolder.tvImageView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(MainActivity.this,GalleryActivity.class);
                    intent.putExtra("image_url",model.getmImageUri());
                    startActivity(intent);
                }
            });

        }

        @NonNull
        @Override
        public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
            View view = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.image_view,parent,false);
            return  new ViewHolder(view);
        }
    };

0 个答案:

没有答案