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

前端 未结 4 2061
误落风尘
误落风尘 2021-01-04 20:03

In my android app, I have a large string resource xml file. I want to make reference and reuse declared resources values within String values. Is it possible to have the R

4条回答
  •  天命终不由人
    2021-01-04 20:50

    Yes, it is possible without writing any Java/Kotlin code, only XML, by using this small library I created which does so at buildtime: https://github.com/LikeTheSalad/android-string-reference

    Usage

    Based on your example, you'd have to set your strings like this:

    
      tbl_name
      create table ${db_table_name}
    
    

    And then, after building your project, you'll get:

    
      create table tbl_name
    
    

提交回复
热议问题