简体   繁体   中英

Android XML include another xml (non layout)

I have a settings.xml file that I use to set various global variables within my app. I want to be able to create sub xml files that I include in the settings.xml file because depending on the client, I change settings in this file so I want to make it easier on myself.

I know that there is a way to include layout files this way but I can't find any documentation that shows how to do this with plain XML on Android.

Any help would be much appreciated.

I think all you have to do is make an additional file which includes the settings you want.

Ie, I have strings.xml in values

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="main_title">Hello there</string>
</resources>

And I can create additionalstrings.xml in the values folder

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="additional">How are you?</string>
</resources>

I can refer to either R.string.main_title or R.string.additional, without having to say the file it came from.

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