【发布时间】:2019-05-23 12:32:49
【问题描述】:
我创建了一个壁纸应用程序,我正在使用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 中显示的任何图像
有什么办法
【问题讨论】:
-
可以将图片直接设置成imageview。
-
如何编码
标签: java android firebase android-adapter android-wallpaper