Hardcoded string, shocould use @ string resource warning

Source: Internet
Author: User

When using eclipse to layout files, sometimes the strings of some controls are edited, and sometimes warnings such as "hardcoded string" Next ", shocould use @ string resource" are prompted, why?

<Button Android: Id = "@ + ID/button1" Android: layout_width = "118dp" Android: layout_height = "wrap_content" Android: text = "Next"/>"

Although the above method can run normally, this is not a good habit. You should set it in RES/values/strings. xml:

<? XML version = "1.0" encoding = "UTF-8"?> <Resources> <string name = "message"> next </string> </resources>

Use Android: text = "@ string/message" for reference. In this way, all changes can be implemented, which is also useful when multiple languages are supported. If you do not want to edit strings. in the XML file, click the textview item of the control in the layout box to create a new string name. in the edit box corresponding to XML, complete the content corresponding to this string.

Http://blog.csdn.net/iqv520/article/details/7579513 # ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.