<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="hello"
/>
在strings.xml配置string的好处:
1.以后修改方便,类似于C/C++中的宏定义
2.为了国际化
3.节省内存,例如:"hello"被用了10000次,就占用了50000个字节,而使用"@string/hello"则会占用5个,其它地方用到时,就直接取得引用。
本文探讨了在XML布局文件中使用字符串资源的优点,包括方便后期维护、支持国际化及节省内存等。通过实例比较直接写入文本与引用字符串资源的不同。
3197

被折叠的 条评论
为什么被折叠?



