R in the Android

by 13:21 0 comments
In Android developing you are using res folder to create resources like music, images, layout files and strings.
But when you want to deal with your resources in your program, How can you do this?

If you are using Android studio, the IDE creates for you class names R.java, It is public static have all values you need to refer to your layout.

Where can I find it? okay usually If you press ctrl and click on any class in your code, Android studio opens it for you.

However, in recent versions of Android Studio if you did that with R class it will open the resource file instead of R.java file.

It is okay you can click double shift and search for R.java, you will find more than one, the one we need is the same have your package name.

R class has inner public static classes those have static final integers, but why integers?

Okay all methods you use to refer for resources like setContentView() takes int parameter (you can check their code, Android is open source).

Good Luck.

Ammar Atef

Blog Creator

Always work and you will be happy, Writing code, designing system and learning some thing new, I call that real life, No matter what is the problem, humanity can solve it any way, Creative one who believes he is creative, Who really watch, think, try and success, World is watching us because we are engineers.


Post a Comment