我正在嘗試將 String 設定為 TextView。但我得到的回應就像
<?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">"Fortune Life"</string>
所以它需要從 xml 到字串的完整字串,但我只想要雙引號內容。即,"Fortune Life"
如何決議 xml 字串?
uj5u.com熱心網友回復:
<?xml version="1.0" encoding="utf-8"?>
<string name="WebsiteTitle">"Fortune Life"</string>
<string name="WebsiteURL">"http://tempuri.org/"</string>
然后您可以將字串用作 R.string.WebsiteTitle 或 R.string.WebsiteURL。要在 TextView 中使用字串,請使用 android:text = "@string/WebsiteTitle" 或 android:text = "@string/WebsiteURL"
uj5u.com熱心網友回復:
那么你需要去 res > values > String.xml
你需要在 String.xml 中設定你的字串


在上圖中,您需要轉到 String xml
<resources>
<string name="app_name">DocumentRecord</string>
<string name="your_title">your title</string>
<string name="your_url"><a href="your_website"></a></string></resources>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/415623.html
標籤:
下一篇:如何使用java讀取XML檔案
