Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Instead of setting the button text to be <code>"add"</code>, set it to be <code>Html.fromHtml("&lt;b&gt;&lt;i&gt;add&lt;/i&gt;&lt;/b&gt;")</code></p> <p>So for with your code:</p> <p>Change these lines:</p> <pre><code>builder.setPositiveButton(R.string.ok_button, null); // and builder.setNegativeButton(R.string.cancel_button, null); </code></pre> <p>To these lines:</p> <pre><code>builder.setPositiveButton(Html.fromHtml("&lt;b&gt;&lt;i&gt;" + getString(R.string.ok_button) + "&lt;/i&gt;&lt;b&gt;"), null); // and builder.setNegativeButton(Html.fromHtml("&lt;b&gt;&lt;i&gt;" + getString(R.string.cancel_button) + "&lt;/i&gt;&lt;b&gt;"), null); </code></pre> <hr> <p><strong>OR</strong></p> <p>you could modify the Strings in your <code>strings.xml</code> file.</p> <p>So for example, if your strings looked like this:</p> <pre class="lang-xml prettyprint-override"><code>&lt;string name="ok_button"&gt;add&lt;/string&gt; &lt;string name="cancel_button"&gt;cancel&lt;/string&gt; </code></pre> <p>you could change them to this:</p> <pre><code>&lt;string name="ok_button"&gt;&lt;b&gt;&lt;i&gt;add&lt;/i&gt;&lt;/b&gt;&lt;/string&gt; &lt;string name="cancel_button"&gt;&lt;b&gt;&lt;i&gt;cancel&lt;/i&gt;&lt;/b&gt;&lt;/string&gt; </code></pre> <p><em>but</em></p> <p>you still are referencing your Strings resources incorrectly. Instead of <code>R.string.ok_button</code>, because that returns an int, you would have to use <code>getString(R.string.ok_button)</code></p> <p>So you would have to change these lines:</p> <pre><code>builder.setPositiveButton(R.string.ok_button, null); // and builder.setNegativeButton(R.string.cancel_button, null); </code></pre> <p>To these lines:</p> <pre><code>builder.setPositiveButton(getString(R.string.ok_button), null); // and builder.setNegativeButton(getString(R.string.cancel_button), null); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload