如何在字符串数组中的字符串下划线

发布于 2024-12-05 03:46:54 字数 577 浏览 0 评论 0原文

我在 strings.xml 中有一个字符串数组。如何为 item 中的字符串添加下划线?

对于字符串,我们这样做。

  <string name="clickable_string">This is a <u>clickable string</u></string>

我尝试了这样的事情。

    <string-array name="products">
        <item>this is a <u> clickable</u> string </item>
        <item> <u> clickable</u> string </item>
        <item>this is a <u> clickable</u> string </item> 
     </string-array>

它不起作用。我怎样才能做到这一点? 谢谢

I have a string-array in strings.xml. How can I underline the string in item?

For string we do like this..

  <string name="clickable_string">This is a <u>clickable string</u></string>

I tried something like this.

    <string-array name="products">
        <item>this is a <u> clickable</u> string </item>
        <item> <u> clickable</u> string </item>
        <item>this is a <u> clickable</u> string </item> 
     </string-array>

Its not working. How can I do that?
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离去的眼神 2024-12-12 03:46:54

尝试这种方式它会工作

 <string-array name="description">
     <item> <Data> <![CDATA[ Check this <u>Redirect to Next Activity</u> ]]></Data> </item>
 </string-array>

在java代码中使用这个:

    ArrayList<String> title_list = new ArrayList<String>();
    String[] description_Array = getResources().getStringArray(R.array.description);
    String categoryAndDesc = null;
    for(String cad : description_Array) {
      categoryAndDesc = cad;
      title_list.add(categoryAndDesc);
    }
    CharSequence sequence = Html.fromHtml(categoryAndDesc);

    seperator_view.setText(strBuilder);
    seperator_view.setMovementMethod(LinkMovementMethod.getInstance());

Try this way it will work

 <string-array name="description">
     <item> <Data> <![CDATA[ Check this <u>Redirect to Next Activity</u> ]]></Data> </item>
 </string-array>

In java Code use this :

    ArrayList<String> title_list = new ArrayList<String>();
    String[] description_Array = getResources().getStringArray(R.array.description);
    String categoryAndDesc = null;
    for(String cad : description_Array) {
      categoryAndDesc = cad;
      title_list.add(categoryAndDesc);
    }
    CharSequence sequence = Html.fromHtml(categoryAndDesc);

    seperator_view.setText(strBuilder);
    seperator_view.setMovementMethod(LinkMovementMethod.getInstance());
忱杏 2024-12-12 03:46:54

试试这个:(

<string name="clickable_string">This is a <u>clickable string</u></string>

即)替换 <和>与<和>在您的 strings.xml 中获取 HTML 格式的内容。

并在您的代码中使用:

String text = context.getString(R.string.clickable_string);
myTextView.setText(Html.fromHtml(text));

Try this:

<string name="clickable_string">This is a <u>clickable string</u></string>

(i.e) Replace the < and > with <; and >; in your strings.xml for HTML formatted content.

And in your code use:

String text = context.getString(R.string.clickable_string);
myTextView.setText(Html.fromHtml(text));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文