• <i id='Fna0d'><tr id='Fna0d'><dt id='Fna0d'><q id='Fna0d'><span id='Fna0d'><b id='Fna0d'><form id='Fna0d'><ins id='Fna0d'></ins><ul id='Fna0d'></ul><sub id='Fna0d'></sub></form><legend id='Fna0d'></legend><bdo id='Fna0d'><pre id='Fna0d'><center id='Fna0d'></center></pre></bdo></b><th id='Fna0d'></th></span></q></dt></tr></i><div id='Fna0d'><tfoot id='Fna0d'></tfoot><dl id='Fna0d'><fieldset id='Fna0d'></fieldset></dl></div>

        <bdo id='Fna0d'></bdo><ul id='Fna0d'></ul>
    1. <legend id='Fna0d'><style id='Fna0d'><dir id='Fna0d'><q id='Fna0d'></q></dir></style></legend>
      1. <small id='Fna0d'></small><noframes id='Fna0d'>

      2. <tfoot id='Fna0d'></tfoot>

      3. Android:资源字符串自动生成

        时间:2023-08-22

        <small id='8jdvK'></small><noframes id='8jdvK'>

        <legend id='8jdvK'><style id='8jdvK'><dir id='8jdvK'><q id='8jdvK'></q></dir></style></legend>
          • <tfoot id='8jdvK'></tfoot>
            • <bdo id='8jdvK'></bdo><ul id='8jdvK'></ul>
                  <tbody id='8jdvK'></tbody>
                • <i id='8jdvK'><tr id='8jdvK'><dt id='8jdvK'><q id='8jdvK'><span id='8jdvK'><b id='8jdvK'><form id='8jdvK'><ins id='8jdvK'></ins><ul id='8jdvK'></ul><sub id='8jdvK'></sub></form><legend id='8jdvK'></legend><bdo id='8jdvK'><pre id='8jdvK'><center id='8jdvK'></center></pre></bdo></b><th id='8jdvK'></th></span></q></dt></tr></i><div id='8jdvK'><tfoot id='8jdvK'></tfoot><dl id='8jdvK'><fieldset id='8jdvK'></fieldset></dl></div>

                  本文介绍了Android:资源字符串自动生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Android 新手.当我在图形布局中添加按钮/视图时,它会以这种方式添加标签文本 - android:text="Button" .为什么不加"android:text="@string/my_label",在string.xml文件里加个字符串资源,eclipse中不能自动完成吗?

                  I'm new to Android. When I add a button/views in Graphical layout it adds the label text this way- android:text="Button" . Why doesnt it add "android:text="@string/my_label" and add a string resource in string.xml file. Can't it be done automatically in eclipse?

                  推荐答案

                  因为您不必使用@string 资源.@strings 资源的目的是使更改代码元素变得更加容易.例如,如果您在多个地方使用您的应用程序标题,假设在每个对话框中,那么如果您更改标题,则必须在显示应用程序标题的所有实例中更改它.因此在这种情况下,@string/App_Title 可以设置为我的程序",并且所有对话框都可以引用它.如果您将标题更改为Hello World",那么所有这些都会更改.@strings 资源,虽然 eclipse 尝试,但不必用于每个字符串.不使用它相当于对值进行硬编码.有很多理由支持和反对使用@string.

                  Because you don't have to use the @string resource. The purpose of the @strings resource is to make it easier to change elements about your code. For example, if you are using your application title in mutliple places, let's say in every dialog box, then if you change the title you would have to change it in all the instances that the app title is being display. So in this instance the @string/App_Title could be set to "My Program" and all of the dialog boxes can reference that. If you change the title to "Hello World" then all of these are changed. The @strings resource, while eclipse tries, doesn't have to be used for every string. Not using it is the equivalent to hard coding the value. There are plenty of reasons for and against using @string for everything.

                  不知道eclipse中是否有设置在添加控件时会自动将字符串添加到资源文件中.

                  I am not sure if there is a setting in eclipse that will automatically add a string to the resource file when the control is added.

                  (基于其他用户,CTRL+1 是执行此操作的捷径.)

                  ( Based on other users CTRL+1 is the short cut to do this.)

                  这篇关于Android:资源字符串自动生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Eclipse IDE:安装 Android SDK 后无法初始化监控线程错误? 下一篇:为什么 IResource.getRawLocation() 为 IProject 返回 null

                  相关文章

                • <legend id='MghgS'><style id='MghgS'><dir id='MghgS'><q id='MghgS'></q></dir></style></legend>

                  <small id='MghgS'></small><noframes id='MghgS'>

                  <tfoot id='MghgS'></tfoot>

                    1. <i id='MghgS'><tr id='MghgS'><dt id='MghgS'><q id='MghgS'><span id='MghgS'><b id='MghgS'><form id='MghgS'><ins id='MghgS'></ins><ul id='MghgS'></ul><sub id='MghgS'></sub></form><legend id='MghgS'></legend><bdo id='MghgS'><pre id='MghgS'><center id='MghgS'></center></pre></bdo></b><th id='MghgS'></th></span></q></dt></tr></i><div id='MghgS'><tfoot id='MghgS'></tfoot><dl id='MghgS'><fieldset id='MghgS'></fieldset></dl></div>
                      • <bdo id='MghgS'></bdo><ul id='MghgS'></ul>