mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
10/28/12 07:27 PM (13 years ago)

how to reference images for android project

This is probably a very easy question for someone to answer. I'm used to xcode where it didn't really matter what folder you put files in, everything worked in the end. My app has quite a few html files and some of those have png files associated with them. Again, in xcode I just threw them all together. I'm having a problem with android because the html and png files often have the same name (ie home.png and home.html). I tried putting all the files into the drawable folder and that almost gave eclipse a heart attack. So I took the html files out and put them into the BT_Docs folder. however now when I pull up that html screen in the app the image doesn't load. Any suggestions?? Right now the image files are referenced in the html as just "home.png" for example. Do I have to change it to "/drawable/home.png? Thanks for the help as usual! Josh
 
Paul Rogers
Android Fan
Profile
Posts: 2524
Reg: May 30, 2011
UK
35,740
like
10/28/12 08:07 PM (13 years ago)
You can throw them all together in the assets directory. I usually create a new directory in assets - www - and put everything in it, usually like a regular website with image/css/script directories etc. Just make sure url paths are relative and it should be fine. The url in the customURL plugin would be file:///android_asset/www/home.html *If you still have trouble after that (you shouldn't), try changing image paths from home.png to /home.png
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
10/29/12 09:46 AM (13 years ago)
Hi @raveyd, Love your idea of a w folder. LA
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
10/29/12 09:48 AM (13 years ago)
I actually got it to work okay by just throwing everything into the BT_docs folder. The problem was the html and image files had the same name which eclipse seems to have a problem with. Once I renamed the images to home1.png then kept home.html everything worked fine. Thanks for the help!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.