user4413257
user4413257

Reputation:

Android XML referencing via dollar sign vs dot sign

Why is Android using $ sign to reference nested class, instead of standard . sign. As far as I know, in Java $ is related to inner class context (in stacktrace).

<view class="path.to.Outer$Nested" ... />

In data-binding . sign is being used to reference nested class as expected:

<variable name="..." type="path.to.Outer.Nested" />

Upvotes: 0

Views: 480

Answers (1)

Robert Estivill
Robert Estivill

Reputation: 12477

Because the inner class is not static.

class Parent {

  class Child {
  }
}

would result in Parent$Child while

class Parent {

  static class Child {
  }
}

would be referenced as Parent.Child.

Upvotes: 1

Related Questions