Issue
Is there a cost to using the android string.xml resources? If I want to keep my application size down, which of the following is better
- Declare my string literals within the layout files, as in
<TextView android:text="Hello">
- Use only one string file to store all strings as resources, as in
strings.xml
- Use one string file per activity (so to speak), as in
strings_activity_hello.xml
Solution
There's no cost as far as I know, and these are two major benefits that I know of:
If you use the same string in multiple layouts or classes, you can change it in strings.xml and it will be updated everywhere (you'll never forget to change it somewhere).
You can give people the strings.xml for translation, and create files like strings-es.xml (for Spanish) that Android will use for automatically displaying a translated version of your app based on the device's default language.
I'm sure it affects compilation time but I think the SDK combines and optimizes all of your strings somewhere in the actual APK.
Answered By - afollestad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.