简体   繁体   中英

Are there any side-effects of using multiple string.xml files?

I am currently creating an application that have some strings (>300 for now) and I have some problems to quickly find a string with so many of them. So I was considering the possibility of using several string.xml files instead of only one (string_menu, string_activity1, ...).

Is there any side-effect with this practice? Is it a bad or a good practice?

I ask this because it seems that no many people on the net are using this possibility. So maybe there is some problem with it?

As stated in the documentation you can use whatever filename you want:

The filename is arbitrary. The <string> element's name will be used as the resource ID.

There may be negligible side effects in performance, you can add as much as you can. I have 3 activity files MainActivity , PhotoActivity , UserActivity , create a common strings.xml file and other activity related files.

-strings.xml                    -> create common string values here.
  --strings_main.xml            -> create main activity specific string values here.
  --strings_photo.xml           -> ...
  --strings_user.xml            -> ... etc etc

Hope this is helpful. Thanks!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM