当前位置: 动力学知识库 > 问答 > 编程问答 >

How to skip empty strings with String.format on android?

问题描述:

Users of my app will be able to re-format the information they see - they will need to edit string like:

<b>Movie name:</b> %1$s, <br><b>Country: </b> %2$s.

Then I take this string and apply String.format.

For ex., Country is empty, in result user will see:

Movie name: SomeMovieName, Country:

Is there any way to not show the whole Country line if %2$s is empty?

网友答案:

Yes <br><b>Country: </b> needs to be included in the replacement string "Country" rather than in the final formated string.

分享给朋友:
您可能感兴趣的文章:
随机阅读: