Categories
Android

android 字符串格式化

发现没啥好写的,提供个链接吧,查阅方便。

一般用到 String.format与Html.fromHtml
官方上有详细介绍:
http://developer.android.com/guide/topics/resources/string-resource.html

有段时间看了日历的代码,发现Plurals有 xliff 字样,搜索一下,小日本写的
http://linkyou-blog.blogspot.com/2010/02/previously-on-my-last-blog.html
终于弄明白了。

读一些代码,发现string.xml里还发现一些蛮有用的技巧,直接写Unicode码:
用 \u0020 表示空格。
用 \u2026 表示省略号。

android提供的android.text.format 也很有用,比如 Formatter 提供的
public static String formatFileSize(Context context, long number)
就很好用,很多人估计是不知道,自个儿写了这样的函数,重复造车轮。

If you enjoyed this post, make sure you subscribe to my RSS feed!

3 replies on “android 字符串格式化”

hello!This was a really brilliant post!
I come from milan, I was luck to search your topic in bing
Also I obtain much in your blog really thanks very much i will come daily

Leave a Reply

Your email address will not be published. Required fields are marked *