Couple of standard Android things i need cleared up

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Couple of standard Android things i need cleared up

Postby discodowney » Mon Mar 21, 2011 4:12 pm

So im doing Tutorials and im on to sections about images. It says to put them into the folder res/drawable. But i dont have that folder i have three res/drawable-hdpi, res/drawable-ldpi and res/drawable-mdpi. So whats the difference between the three?

Im using a tuorial: ... inner.html

One of the steps is:

Create a strings.xml file in res/values/ and edit the file to look like

There already is a strings.xml. combined with the above tellign me to use res/drawable, are these tutorials out of date?

This tutorial has code like:

R.layout is just simple enuf. uses the main.xml in the layout folder. But where are and R.array to come from. Cos it is coming up in eclipse saying it doesnt know what they are. gets updated automatically, so can someone tell me from reading that tutorial where id gets added to R? It says that

The R.array.planets_array ID references the string-array defined above

Only it doesnt work. I doubt it makes a difference that i didnt make strings.xml since its the same filename in the same location. But since is meant to be updated automatically i dont know how to fix this.
Junior Developer
Junior Developer
Posts: 10
Joined: Wed Mar 02, 2011 3:10 pm


Re: Couple of standard Android things i need cleared up

Postby Faded9 » Tue Mar 22, 2011 7:50 pm

That tutorial is probably rather old by now, but it's not really "out-of-date" since it is simple and can still be used fine with the current systems. Even a lot of newer tutorials refer to the three "drawable-_dpi" folders as "res/drawable" to keep things simple, even though that folder was replaced by the new ones (Now four, ldpi, mdpi, hdpi, xhdpi) with newer versions.

Those folders are essentially all the same thing as the original "res/drawable". The difference is that the Android system looks at the dpi of the phone screen that the app is running on, and tries to find the resources for your app from the corresponding folder. So if you have a phone with a high density screen, it will try to find your image resources in the "drawable-hdpi" folder first, if it doesn't find it there it will just try to find it elsewhere. This doesn't necessarily mean you need to utilize them, you can just put all you images in one folder as you would with the classic "drawable" folder, but it is a very handy feature that simplifies making your app more compatible with a range of devices. I don't want to type up a book here, but I really recommend reading the following article, it will make things much clearer for you : ... pport.html

I can't remember if strings.xml was always created by default, but maybe it wasn't pre-1.6 when I figure that was written. Either way, you were correct in that you didn't need to create one. Just modifying the file there would be fine.

I did the first half of that tutorial to see where your problem was coming from. It seems that there's a slight mistake in what they have you put into the strings.xml file. When a project is created the strings.xml file automatically has a string in there named "app_name", which AndroidManfiest.xml refers to for the actual app name. It isn't a very intuitive error, but calling strings that don't exist and what not causes those strange issues with resources not being defined and what not. Just add in :

Code: Select all
    <string name="app_name">HelloSpinner</string>

to your strings.xml and that should fix that.

If you're still having issues post back and I will look into it a bit more. Good luck!
Junior Developer
Junior Developer
Posts: 16
Joined: Tue Mar 22, 2011 7:14 pm


Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 3 guests