在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "BUTTON", should use @string resource [html]  view plain copy
  1. <Button  
  2.         android:id="@+id/button1"  
  3.         android:layout_width="118dp"   
  4.         android:layout_height="wrap_content"  
  5.         android:text="button" />"  
虽然可以正常运行,但是这不是一个好习惯,应该在res/values/strings.xml中设置: [html]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <string name="message">buttonstring>  
  4. resources>  
引用的时候使用
android:text="@string/message"
就行了。这样做可以做到一改全改,在支持多语言时也是很有用的。另外,颜色的设置也最好在color.xm中类似设置。

更多相关文章

  1. Android Layout的layout_height等属性为什么有时会不起作用?
  2. Android NDK编程中Application.mk和Android.mk写法
  3. Android ViewPager和PagerAdapter简单代码写法
  4. Android 自定义view的写法
  5. startService写法
  6. Android Timer计时器简单写法
  7. 【转】android编译系统的makefile文件Android.mk写法

随机推荐

  1. 微信接口 - android
  2. android 全志a10(2.3.4)开发三 (打包编译文
  3. Android多国语言使用须知
  4. Android字符串资源及其格式化
  5. 【Android】Parse 开发笔记(3)—— 实现查
  6. android去掉Edittext的下边线
  7. Android(安卓)Bitmap压缩策略
  8. android 列出所有的应用
  9. Android(安卓)Gradle 学习笔记整理
  10. Android(安卓)Cursor浅析