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).