在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "BUTTON", should use @string resource

<Button
        android:id="@+id/button1"
        android:layout_width="118dp"
        android:layout_height="wrap_content"
        android:text="下一步" />"

虽然可以正常运行,但是这不是一个好习惯,应该在res/values/strings.xml中设置:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="message">下一步</string>
</resources>

引用的时候使用

android:text="@string/message"

就行了。这样做可以做到一改全改,在支持多语言时也是很有用的。另外,颜色的设置也最好在color.xm中类似设置。

android学习—should use @string resource警告的更多相关文章

  1. Hardcoded string should use @string resource 警告

    在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string "下一步", should use @string resource <Button and ...

  2. Hardcoded string "下一步", should use @string resource警告 (转载)

    转自:http://blog.csdn.net/iqv520/article/details/7579513 在布局文件中,文本的设置使用如下写法时会有警告:Hardcoded string &quo ...

  3. 转 Android学习笔记: 学习过程中碰到的一些问题及解决方法

    在学习Android开发的过程中遇到了不少的问题,所幸的是最终经过上网查询都得到了解决.现在将我在学习Android开发过程中遇到的一些问题及解决的方法整理如下. 1.R.java不能实时更新 问题描 ...

  4. (转载)android:android.content.res.Resources$NotFoundException: String resource ID #..

    android.content.res.Resources$NotFoundException: String resource ID #0x0 找不到资源文件ID #0x0 原因分析如下: 遇到这种 ...

  5. android.content.res.Resources$NotFoundException:String resource ID #ffffffff

    无语,搞了半天,只能去插这个错误代号,结果就找到了这个结果. scoreTextView.setText(score+""); 这个一定要自己手动转换..不科学啊..关键是在ecl ...

  6. android.content.res.Resources$NotFoundException: String resource ID #0x1

    之前忘了记录这个错误,今天又遇到了.唉,人不能纵容自己犯懒,遂记录之. 错误:android.content.res.Resources$NotFoundException: String resou ...

  7. Android报“android.content.res.Resources$NotFoundException: String resource ID #0x2”错误

    Android报“android.content.res.Resources$NotFoundException: String resource ID #0x2”错误 当调用setText()方法时 ...

  8. 异常 android.content.res.Resources$NotFoundException: String resource ID #0x61

    09-09 16:08:41.554: E/Weaver(13140):09-09 16:08:41.554: E/Weaver(13140): android.content.res.Resourc ...

  9. Android Problem- android.content.res.Resources$NotFoundException: String resource ID #0xa

    在使用listview时出现错误android.content.res.Resources$NotFoundException: String resource ID #0xa 经查证是在调用Text ...

随机推荐

  1. (转) Data structures

      Data structures A data structure is a group of data elements grouped together under one name. Thes ...

  2. (原)安装windows8.1和ubuntu16双系统及相互访问磁盘

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5638232.html 参考网址: http://jingyan.baidu.com/article/f ...

  3. 修改mysql编码为UTF-8

    mysql> show variables like '%character%'; +--------------------------+--------------------------- ...

  4. 两个string数组对应比较

    最近做的array string类型对比.这个可能比较复杂,用的是linq 是请教别人的,我在这里记录一下 jquery 方法里面的数组 function arrtxt() { var arrt= [ ...

  5. 解决mysql中文存储问题

    在mysql安装目录下先找到my.ini,给[mysql]和[mysqld]下的default-character-set赋值为utf8 即改为:default-character-set=utf8 ...

  6. shell date格式化输出

    1-  echo `date "+%Y-%m-%d %H:%M:%S"` 2014-11-13 15:06:26 2-  echo `date "+%y-%m-%d %H ...

  7. Integer和Integer数据的大小比较

    public class Test{ public static void main(String[] args){ Integer i1 = 100; Integer i2 = 100; if(i1 ...

  8. 关于STM32工程的错误,狗血错误。。。..\CMSIS\core_cm3.h(1087): error: #20: identifier "IRQn_Type" is undefined

    这件事还是要写一篇博客了,为了后来的人不换致命性的错误 辛辛苦苦写的一个四个不同的引脚不同时钟不同寄存器分别产生四种不同占空比不同周期的信号方波程序超级经典  PS:页尾上传PWM波形产生工程附件供大 ...

  9. order by 中 使用decode

    表内容如下: 实现以name字段中的ABCDE的顺序排序,以及按照money字段从小到大排序. select name,money from t2 ,,,,) , money

  10. CEF3 怎样禁止右键菜单

    CEF3 怎样禁止右键菜单 (2013-07-30 11:56:34)转载▼标签: cef3 右键菜单 分类: CEF3问题描述:CEF3 嵌入成功后,在网页点鼠标右键,出现英文菜单,应该怎样禁止掉呢 ...