Simple example of resource file usage in Android _android

Source: Internet
Author: User
Tags sqlite database

This example describes the usage of resource files in Android. Share to everyone for your reference, specific as follows:

Use of resource files between XML files

Reference format:

Attribute= "@[packagename:]resourcetype/resourceidentifier"

Example

There are Strings.xml, Color.xml, dimen.xml files, using the parameters in them

<?xml version= "1.0" encoding= "Utf-8"?> <linearlayout xmlns:android=
"http://schemas.android.com/" Apk/res/android "
android:orientation=" vertical "
android:layout_width=" fill_parent "
android:layout_" height= "Fill_parent"
android:padding= "@dimen/standard_border" >
<edittext android:id=
"@+id/ Myedittext "
android:layout_width=" fill_parent "
android:layout_height=" Wrap_content "
android: text= "@string/stop_message"
android:textcolor= "@color/opaque_blue"
/>
</LinearLayout>

Ii. resources for using the system

Use Android Local system resources to write this:

Copy Code code as follows:
Charsequence httperror = getString (Android. R.string.httperrorbadurl);

How to use in an XML file:

<edittext
android:id= "@+id/myedittext"
android:layout_width= "fill_parent"
android:layout_height = "Wrap_content"
android:text= @android: String/httperrorbadurl "
android:textcolor=" @android: color/ Darker_gray "
/>

Note that the Android prefix is added to the file that references the local resource.

For more information on Android-related content readers can view the site topics: "Android Resources Operating Skills Summary", "Android File Operating skills summary", "Android operation SQLite Database Skills Summary", " Android operations JSON format Data tips summary, "Android Database Operation skills Summary", "Android programming activity Operation Skills Summary", "Android programming development of SD card operation method Summary", "Android Development and advanced tutorial ", the Android View View tips Summary" and the Android Control usage summary

I hope this article will help you with the Android program.

Related Article

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.