我正在将图像上传到 firebase 存储,然后将该图像的名称和 url 推送到数据库中。接下来,我将检索图像 url,以在我的 recyclerview 中显示图像。现在我想在 recyclerview 启动时显示上传到 firebase 存储的最新图像。如何更改 Firebase 数据库中的顺序?现在,您添加的第一张图像是数据库中的第一张图像。我想要用户上传的最新图像,该图像的 url 应位于 firebase 数据库的顶部。每个图像Name: tomDesc: 1Url: anyName: mikiDesc: 2Url: any描述: 1 是最旧的描述: 2 是最新的如何更改订单请给我完整的代码壁纸活动public class WallpapersActivity extends AppCompatActivity {List<Wallpaper> wallpaperList;List<Wallpaper> favList;RecyclerView recyclerView;WallpapersAdapter adapter;DatabaseReference dbWallpapers, dbFavs;ProgressBar progressBar;@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wallpapers); Intent intent = getIntent(); final String category = intent.getStringExtra("category"); Toolbar toolbar = findViewById(R.id.toolbar); toolbar.setTitle(category); setSupportActionBar(toolbar); favList = new ArrayList<>(); wallpaperList = new ArrayList<>(); recyclerView = findViewById(R.id.recycler_view); recyclerView.setHasFixedSize(true); recyclerView.setLayoutManager(new LinearLayoutManager(this)); adapter = new WallpapersAdapter(this, wallpaperList); recyclerView.setAdapter(adapter); progressBar = findViewById(R.id.progressbar); dbWallpapers = FirebaseDatabase.getInstance().getReference("images") .child(category); if(FirebaseAuth.getInstance().getCurrentUser() != null){ dbFavs = FirebaseDatabase.getInstance().getReference("users") .child( FirebaseAuth.getInstance().getCurrentUser().getUid() ) .child( "favourites" ) .child( category ); fetchFavWallpapers( category ); }else { fetchWallpapers( category ); }}
添加回答
举报
0/150
提交
取消