Trying to use <!ENTITY in ANDROID resources with error: “The entity was referenced, but not declared.”

后端 未结 4 869
清酒与你
清酒与你 2020-12-09 16:42

I\'m following this solution to use enetities in my string resource file:

Is it possible to do string substitution in Android resource XML files directly?

I\

4条回答
  •  佛祖请我去吃肉
    2020-12-09 17:00

    Alternatively, if you still prefer avoiding resolving placeholders on Java/Kotlin and rather get them resolved in the XML files, then you could use this small library I created: https://github.com/LikeTheSalad/android-string-reference which will allow you to do something like this:

    
        MyDeviceName
        The name is ${devicename}
    
    

    And then, you make/build the project, and a new file will be generated with:

    
        The name is MyDeviceName
    
    

    More info on the repo provided above.

提交回复
热议问题