简体   繁体   中英

android replace drawable image programmatically

I have 10 images in drawable directory in my android project and I'm using those images in a gallery. I want to replace those 10 images programatically upon user request to download new images from the web.

Is this possible to replace the images in drawable of my App with downloaded images?

Thanks in advance

This is not possible. You will have to download and store it on disk. Either in internal memory or External memory.

No, this is impossible act. You cant manipulate any resource of APK(read-only).

You can store your image either in your Phone memory(Internal or External) or You can just create a Drawable(cache) at Runtime and flushed it.

You having directory called /data/data/package_name this folder will gets delete once you uninstall your Application and for other directory you have to delete manually.

您不能以编程方式更改应用程序的资源(如@hotveryspicy所说),但您可以为应用程序创建特定目录(应用程序的私有目录或公共目录)并将图像下载到它。当您的应用程序要显示图像时检查该指示灯中是否存在图像,显示图像中的图像,否则显示其资源中的图像。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM