How to put variable inside string-resources?

后端 未结 4 403
情歌与酒
情歌与酒 2020-12-08 18:07

Is it possible to put variables inside string-resources? And if yes - how do i use them.

What i need is the following:

4条回答
  •  [愿得一人]
    2020-12-08 19:00

    Just pass it throught getString() function as formatArgs Object.

    int nextResultsSize = getNextResultsSize();
    String strNextResultsSize = 
         getResources().getString(R.string.next_x_results, nextResultsSize);
    

    XML:

    Next %1$d results
    

提交回复
热议问题