在布局文件中,文本的设置使用如下写法时会有警告: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. ongl三种符号的使用

    1.#符号 访问非根对象属性,由于Struts2中值栈被视为根对象,所以访问其他非根对象时,需要加#前缀.实际上,#相当于ActionContext.getContext(): 用于过滤和投影(pro ...

  2. MYSQL数据去重与外表填充

    经常要对数据库中的数据进行去重,有时还需要使用外部表填冲数据,本文档记录数据去重与外表填充数据. date:2016/8/17 author:wangxl 1 需求 对user_info1表去重,并添 ...

  3. OpenCV——IplImage

    IplImage结构: typedef struct _IplImage { int nSize; /* IplImage大小 */ int ID; /* 版本 (=0)*/ int nChannel ...

  4. poj1716 Integer Intervals(差分约束)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Integer Intervals Time Limit: 1000MS   Me ...

  5. css让图片居中显示在手机屏幕上

    直接上代码了 <div class="showpic"> <span></span> <img src="" alt= ...

  6. 理解Python中的装饰器

    文章先由stackoverflow上面的一个问题引起吧,如果使用如下的代码: @makebold @makeitalic def say(): return "Hello" 打印出 ...

  7. linux下安装pdf

    官方下载地址:http://www.foxitsoftware.cn/downloads/ 问题:下载官方包以后解压,双击不能打开,也没有任何提示. 用teminal 来打开foxitreader,t ...

  8. ubuntu下安装fiddler

    因为工作中需要用到fiddler工具  现在工作环境迁移到ubuntu14 下  发现fiddler只支持windows网上也有很多推荐 号称可以代替fiddler   但因为功能使用上比较习惯  并 ...

  9. jquery.fn.extend与jquery.extend(转)

    jQuery为开发插件提拱了两个方法,分别是: JavaScript代码 jQuery.fn.extend(object); jQuery.extend(object); jQuery.extend( ...

  10. curl fake ip

    curl --header "X-Forwarded-For: 219.137.148.2" "http://www.x.com"