<分区>
1) 我有一个 android 应用程序,它有一个默认的背景 Image()
2) 我有一个登录页面,用户可以在其中从下拉列表中选择一个项目..并根据该项目调用 API 来下载图像。
3) 下载图片后,我想更改该页面的背景并缓存它,以便在其余页面中使用相同的图片
任何人都可以建议一种方法来做到这一点。 AM 从几个小时开始就一直在寻找解决方案
请帮忙!!
<分区>
1) 我有一个 android 应用程序,它有一个默认的背景 Image()
2) 我有一个登录页面,用户可以在其中从下拉列表中选择一个项目..并根据该项目调用 API 来下载图像。
3) 下载图片后,我想更改该页面的背景并缓存它,以便在其余页面中使用相同的图片
任何人都可以建议一种方法来做到这一点。 AM 从几个小时开始就一直在寻找解决方案
请帮忙!!
最佳答案
1) I have a android application which has a default background Image()
好的开始
2) I have a login page where the user selects an item from a drop down list ..and depending on the item i make an API call to download an image
使用AsyncTask在 doInBackground()
3) Once the Image is downloaded i want to change the background of that page and also cache it so as to use the same image in rest of the pages
您可以在 AsyncTask
的 onPostExecute()
中更新背景。将图像保存在数据库中,或者可能只是保存到设备上的文件中,或者作为全局类中的 static
变量(大多数人不推荐)
我希望这可以帮助你开始
关于java - 下载后动态更改背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17996606/