Understanding Resources

| |
Resources in Android are files stored under the res directory of your project. Resources can be physical files (Audio, video, images, text, etc…) or xml files that declare some values to use in your application.

Why use Resources:
  1. The resources are bound to the application in a way that you can change them without needing to change the source code or recompile the application.
  2. The Android Generates an ID for each resource file so you can access them directly and easily. All the resources IDs are added to the R.Java file.
  3. When you use XML resource files, Android pareses these files automatically so you can reference values defined in them directly with no extra effort.
  4. Using resources is very useful in Localization and Internationalization of the application in case you develop multilingual applications. This includes not just the labels but it can include alignment, directions images or any kind of files.
Types of resources:
  • Strings, colors, arrays, dimensions. Defined in res/values/ directory. Using them is very useful in Localization and Internationalization.
  • Images put in res/drawable directory. You can put all the images or icons you need in your application.
  • Animations, defined in res/anime/ directory. You can define animations that for example correspond to a button click.
  • XML, defined in res/xml/ directory for xml files containing your custom data.
  • Layout resources, defined in res/layout/ for declaring the views that construct the user interface of the activities.

Related Posts by Categories

0 comments:

Post a Comment