Android XML referencing via dollar sign vs dot sign

霸气de小男生 提交于 2019-12-12 04:21:21

问题


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" />

回答1:


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.



来源:https://stackoverflow.com/questions/44827890/android-xml-referencing-via-dollar-sign-vs-dot-sign

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!