欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
Android資源的使用之String - 悟道 - 博客園

Android資源的使用之String

Android允許定義多個(gè)字符串資源文件在res/values 中

1 <?xml version="1.0" encoding="utf-8"?>
2 <resources>
3     <string name="hello">Hello World!</string>
4     <string name="app_name">App Name</string>
5 </resources>

當在此創(chuàng )建或修改資源文件時(shí),ADT都會(huì )自動(dòng)更新R.java ,并產(chǎn)生唯一的標識符來(lái)標識,如:

1 public static final class string {
2 public static final int app_name=0x7f040004;
3 public static final int hello=0x7f040003;
4 }

在程序中使用資源就可以用R.string.hello來(lái)標識字符串了,并可用Activity中的getText(R.string.hello)直接轉成字符串

特殊格式字符串 

代碼
<resources> 
    
<string name="java_format_string"> 
           hello %2$s java format string. %1$s again 
     
</string> 
     
<string name="tagged_string"> 
         Hello 
<b><i>Slanted Android</i></b>, You are bold. 
     
</string> 
</resources> 

 

這里的特殊格式字符串指的是帶參數的格式字符串,及帶有HTML標簽的字符串。

讀取操作可以這樣

 

代碼
//Read a Java format string 
String javaFormatString = activity.getString(R.string.java_format_string); 
//Convert the formatted string by passing in arguments 
String substitutedString = String.format(javaFormatString, "Hello" , "Android")
//set the output in a text view 
textView.setText(substitutedString); 
 
//Read an html string from the resource and set it in a text view 
String htmlTaggedString = activity.getString(R.string.tagged_string); 
//Convert it to a text span so that it can be set in a text view 
//android.text.Html class allows painting of "html" strings 
//This is strictly an Android class and does not support all html tags 
Spanned textSpan = android.text.Html.fromHtml(htmlTaggedString); 
//Set it in a text view 
textView.setText(textSpan); 

 

 

支持多國語(yǔ)言

要讓?xiě)贸绦蛑С侄鄠€(gè)語(yǔ)言界面,并不需要重新定義界面。只需要添加一個(gè)語(yǔ)言資源目錄放置相應的字符串資源文件 如:res/values-en 表示英文字符串 ,res/values-zh-rCN表示簡(jiǎn)體中文 res/values-zh-rTW表示繁體中文。

進(jìn)入“設置”程序,選擇“區域和文本”,可以選擇對應的語(yǔ)言測試。

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
string標簽
Python標準庫筆記之string 
URL編碼java
Android?技術(shù)專(zhuān)題系列之五?--?本地化
Android TextView使用HTML處理字體樣式、顯示圖片等
Python教程:字符串對齊的常用方法
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久