Jump to Navigation

Me on Twitter

  • RT @liamstack: This may be my favorite image from the pandemic https://t.co/bx8MZ3bGYX 2 years 46 weeks ago
  • RT @ThePracticalDev: Technology is the fastest-growing industry nowadays, which requires developers to keep up with all the improvements go… 2 years 46 weeks ago
  • Typical #antipattern in #mobile #French apps : blocking app access unless you update it. Don't they know about #API versioning ??? 2 years 47 weeks ago
  • RT @ArtifactsHub_: Ancient Egyptian dental work from 2000 BC https://t.co/9C0tGqu5wC 2 years 47 weeks ago
  • Excellent site about #batteries How to Prolong Lithium-based Batteries - Battery University - https://t.co/H8hUTm38qX 2 years 48 weeks ago
  • RT @SwiftOnSecurity: Breaking: CDC says fully-vaccinated people can turn off SMS 2FA, use the same password for everything again. 2 years 50 weeks ago
  • RT @acupoftim: [1/4] Bonsoir ! Demain sort ma nouvelle bd, "CANEVAS" et à ce sujet j'ai une minuscule demande à faire à vous qui aurez bien… 2 years 50 weeks ago
  • Solar System Cartogram - https://t.co/qU2p1x0WGY 3 years 4 weeks ago
  • RT @moshhamedani: #geek #humor https://t.co/mIVimI89Se 3 years 5 weeks ago
  • J'ai appris des choses https://t.co/kKMpCJ0TAr 3 years 5 weeks ago

XML resources

android How to organise XML resources

The first time I read Android developer docs, there was something that was unclear to me : what resource to put in which XML file.

In this article, I will focus on resources in res/values and give some hints about how to name your XML resource files and what kind of resource to put inside.

...

In my case I had only one or two arrays of strings so it was overwhelming to put them in a separate file just because they were of a different type.

Another problem was accessing constant values from both XML layout and Java code. They are constant strings for internal use only, but in order to avoid duplicate declarations I decided to make them available as XML resources. I wanted those resources to be clearly separated from other, 'user visible', resources like GUI labels.

Another thing adding to the fog was the fact that, in derivate files (e.g. strings-fr.xml is derivated from strings.xml), you only want to find values relevant for the given file.
For instance, if you put all values of type 'string' in the same file but only a part of them should be internationalized, you would have a gap between the original and derivated files not only by the translated values but also by the list of values they declare. When coming back to the project after a long time, you might have a hard time remembering why there is this gap.

...

Syndicate content