java如何使用firebase recyclerview设置壁纸应用程序?
我创建了一个墙纸应用程序,我正在使用Firebase
将图像上传到数据库,并将其显示给RecyclerView
我可以通过RecyclerView
看到我上传到Firebase
中的图像,我还可以将该图像传递给另一个活动
但我的问题是,我无法将图像设置为壁纸,当我设置按钮时,图像正在消失
设置墙纸的代码:
img = (ImageView) findViewById(R.id.images);
Intent intent = getIntent();
String webUrl = intent.getStringExtra("URL");
Picasso.get().load(webUrl).into(img);
fab1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WallpaperManager wallpaper = WallpaperManager.getInstance(getApplicationContext());
try {
wallpaper.setResource(+ R.drawable.pug); //by using this code i can set a image in directory a wallpaper
//wallpaper.setResource(+ R.id.images); //i tried this one it doesn't work it just crashes the app
}catch (IOException e){
e.printStackTrace();
}
}
});
我想要的是设置ImageView
中显示的任何图像
有什么办法吗
# 1 楼答案
我假设你已经获得了许可:
我不确定你想实现什么,但我假设你希望用户从列表中选择一幅图像,并将其设置为壁纸。 只能将
Bitmap
或Resource ID
传递给WallpaperManager
。在这种情况下,首先以Bitmap
的形式获取图像,然后加载到ImageView
中既然你已经在使用毕加索,你可以这样做: