title: How to use formatted strings together with placeholders in Android?
body: <p>In Android it is possible to use placeholders in strings, such as:</p>
  
  <pre><code>&lt;string name="number"&gt;My number is %1$d&lt;/string&gt;
  </code></pre>
  
  <p>and then in Java code (inside a subclass of <code>Activity</code>):</p>
  
  <pre><code>String res = getString(R.string.number);
  String formatted = String.format(res, 5);
  </code></pre>
  
  <p>or even simpler:</p>
  
  <pre><code>String formatted = getString(R.string.number, 5);
  </code></pre>
  
  <p>It is also possible to use some HTML tags in Android string resources:</p>
  
  <pre><code>&lt;string name="underline"&gt;&lt;u&gt;Underline&lt;/u&gt; example&lt;/string&gt;
  </code></pre>
  
  <p>Since the <code>String</code> itself cannot hold any information about formatting, one should use <code>getText(int)</code> instead of <code>getString(int)</code> method:</p>
  
  <pre><code>CharSequence formatted = getText(R.string.underline);
  </code></pre>
  
  <p>The returned <code>CharSequence</code> can be then passed to Android widgets, such as <code>TextView</code>, and the marked phrase will be underlined.</p>
  
  <p>However, I could not find how to combine these two methodes, using formatted string together with placeholders:</p>
  
  <pre><code>&lt;string name="underlined_number"&gt;My number is &lt;u&gt;%1$d&lt;/u&gt;&lt;/string&gt;
  </code></pre>
  
  <p>How to process above resource in the Java code to display it in a <code>TextView</code>, substituting <code>%1$d</code> with an integer?</p>