Skip to content Skip to sidebar Skip to footer

Diferrence Between R & Android.r Class

Can anyone explain from this question; whats the difference of 'R' between R.id.myListView & android.R.layout.simple_list_item_1 Isn't these 2 'R' the same class? * Some peo

Solution 1:

R.layout.*, R.id.*,in fact any R.something without the android.- part in front of it refers to some resource in your resources folders, e.g. drawables, strings, layouts, ids of widgets etc. android.R.* refers to standard android items that come shipped with your SDK

Solution 2:

R.id.myListView 

Your R.java file (Generated automatically in project/gen folder) When your application is compiled, aap generates the R class, which contains resource IDs for all the resources in your res/ directory. For each type of resource, there is an R subclass (for example, R.drawable for all drawable resources) and for each resource of that type, there is a static integer (for example, R.drawable.icon). This integer is the resource ID that you can use to retrieve your resource.

android.R.layout.simple_list_item_1

For example android.R.id.text1 (in Java) is an identifier of a TextView in the Android framework. You can find it in many layouts from the framework (select_dialog_item, select_dialog_singlechoice, simple_dropdown_item_1line, etc.).

Solution 3:

android.R is a built in set of constants provided as a part of the Android app framework. The other R class is a generated representation of your xml resources.

It is valid Java/Android to have multiple classes with the same name, as long as they are in different packages (which is the case here).

Solution 4:

R.id.MyListview :- R is a class here it is your package Resource

android.R.layout.simple_list_item_1 :- it is android R/Resource class,and you are trying to use it to get layout id of simple_list_item layout

Solution 5:

R.* is defined by yours. android.R.* is pre defined.

Post a Comment for "Diferrence Between R & Android.r Class"