I am newbie to Android and playing with some Hello World codes.I observed that android put every resource i.e. image,string etc in res
folder and we 开发者_如何学JAVAaccess it like @drawable/icon
i.e icon
image in drawable folder or like R.layout.main
which means main.xml
inside layout
folder.
But while accessing strings we use @string/string_name
but we dont specify its parent folder name i.e.values
.Why syntax differs for strings
?
All resources of the same type in android is in a flat hierarchy. You don't specify a directory name but instead the type of the resource.
Even if you split all strings between different files it will always be @string/string_name
I'm afraid.
A good thing you can do to get some structure is to do something similar to this:
@string/error_network_io @string/error_network_unknown_host @string/message_save_successful ...
精彩评论