As you know you can write whatever resource you need inside res/values
.
I made an xml file for each gui/activity I'm using. Here's an example:
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">This is home!</string>
<string name="app_name">Hattrick4Manager</string>
<string name="oauth_button">Authorize me!</string>
<string name="download_button">Syncronize</string>
<string name="oauth_name">Authorization</string>
</resources>
update-ui.xml
<resources>
<string name="inizio_download">Update Started...</string>
<string name="fine_download">Update Completed...</string>
<string name="update_title">Update</string>
<string name="update_done">Done</string>
<string name="update_inizio_club">Club...</string>
<string name="update_inizio_arena">Arena...&l开发者_运维百科t;/string>
<string name="update_inizio_fan">Fans...</string>
<string name="update_inizio_matches">Matches...</string>
<string name="update_inizio_league">League...</string>
<string name="update_inizio_leaguefix">League Fixtures...</string>
<string name="update_inizio_economy">Economy...</string>
<string name="update_inizio_players">Players...</string>
</resources>
When I use this in the code I have to recall them like:
R.string.update_done
or
R.string.hello
my problem is that like this I have basically to add the prefix for every GUI I make. I would prefer doing something like:
R.string.update-ui.done
Is it possible?
You can create as many resource files as you want, but you can not perform the nested name referencing based on the filename: the Android aapt
tool doesn't support arbitrary nested objects on the generated R
object.
You might be able to do stuff like this in update-ui.xml
:
<resources>
<string name="update_ui_inizio_download">Update Started...</string>
<string name="update_ui_fine_download">Update Completed...</string>
</resources>
and then use
R.string.update_ui_inizio_download
to reference the contents of the file
精彩评论