2011-09-14 49 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

相關問題