2011-09-14 50 views
0

我在strings.xml中有一个字符串数组。我如何在项目中加下划线?如何在字符串数组中加下划线

对于我们做这样的字符串..

<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> 

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

回答

2

尝试这种方式,将工作

<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()); 
+0

谢谢@Venky ...它的工作.. :) – sam

1

试试这个:

<string name="clickable_string">This is a &lt;u&gt;clickable string&lt;/u&gt;</string> 

(即)更换<和>与& LT ;和& GT ;在的strings.xml为HTML格式的内容。

并在代码中使用:

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

谢谢@Raghunath ..For串它的工作。我正在寻找解决方案的字符串.. – sam

+0

做同样的内部这就是全部:) –

+0

没有@Raghunath ..它不是这样工作...尝试像venky说,它的工作,但同样的字符串正在接... ..最后输入的数据...谢谢你的回复.. – sam

相关问题