replace images in data from webservice android - android

Hi all,
How can i replace the text or symbol from web service with local images in drawable folder.
I get a symbol and text from web service. I need to replace that symbol with my image that is saved in local drawable folder in the application.
Please suggest few ideas of how can i do that.
Thanks in advance.

You cannot change or add any drawables inside your drawable folder. These resources are compiled into an .apk file, and there is no way to change them at runtime. Only solution I see is to store downloaded images on SD card and fetch them when you need it. Hope this helps.

Related

Setting ImageView src from an image in Windows's drive

I have an image in my D drive (D:\...\Image.jpg) and I want to display it in my app, the thing is Im getting the image name from the database, and in my code Im doind something like:
image_view.setImageBitmap(BitmapFactory.decodeFile("D:\\Program Files\\Image_Folder\\"+item.Img_Name));
But Im getting an error saying there is no such file as (D:\Program Files...\Image.jpg), basically it's a No File Found Exception but Im sure the path is correct.
So I can't add it to drawable folder because I don't know wich image the user will select, and it would be silly to put all the images in the drawable folder to avoid this problem.
Any Ideas ?! Thank you.
You can't access images on another device like that. You need to either put all the images you need in the drawable folder, or set up a webserver on which you can get the images over a network connection.
You can get image only from device file directory, assets or drawable folders.
You can't access from your local drive it is supposed to be somewhere in your package or alternatively if only local directory is the option you can setup an ftp server through FileZilla (Server) and access your local drive through sharing.
Thanks

Adding a drawable to resources programmatically and getting the list of all drawables programmatically

I need to implement the following functionality: download an image from the internet, and add it as a drawable to resources.
I will also need to get a list of all drawables programmatically when app starts. I can get a drawable from resources by it's id, but the list of drawables will be dynamic, so I will not have the IDs of the drawables.
If someone has a solution for this, help would be greatly appreciated.
download an image from the internet, and add it as a drawable to resources.
That is not possible. Resources are read-only at runtime. You are welcome to download the image to internal storage and use it from there.
I will also need to get a list of all drawables programmatically when app starts
For the ones you download to internal storage, use standard Java file I/O to list the files in your chosen directory (e.g., listFiles() on the File pointing to that directory).
For any actual drawable resources that you want to look up dynamically, that's not really recommended. That being said, you can hack in some reflection to make it work.

How to implement imageswitcher code in android application?

I want to get images name from database and images are stored in the resource folder
Could you show me how to do it.
I tried few methods but none works.
You cant do it, resource folder is read only folder, and the R.java also generated at compiled time, not in runtime. You can save the image in sd card or cache memory .

To copy an image from an sdcard into res/drawable folder of the Android app

I would like to know the possibility of copying an image from the sdcard in to the res/drawable folder of an Android application , these are very small Bitmaps located in an sdscard.
thanks in advance
Thank you for patiently answering my question , I am trying to locally store my bitmaps into the app local data location.
Its not possible to edit res folder as it has to be filled up at compile time in order to let the compile generate the R.java file.
It is not possible to add image to drawable directory pro-grammatically.

How to download a image to a drawable folder from a url?

I would like to add a image to a xml image view, and needs to be updated on timely basis.Whether is there a possibilty of updating directly to the drawables or how to do it from device memory i.e. downloading & calling from internal memory to the xml imageview.Kindly help me with an example or a snippet.Thank you.
Not possible. You will have to save image either to the SD CARD or the
data/data/package folder. You can not write/save image in drawable/res. Sorry.
You cannot update drawable folder.Only thing you can do is save the image in sdcard or in application memory ie /data/data//image.png.To set the image dynamically you can get reference of your image in your activity using findviewbyid and then set its image wherever required.
Research a bit before you ask a question...
During runtime you do not have access to your projects folders, as they are compiled to .apk file and that file runs on the device, now how on earth can you modify those folders while your app is running?
Try downloading it to your SD card or internal memory instead...

Categories

Resources