two views with same id

后端 未结 3 601
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 04:32

How does android use R.id.id_name to find views after inflating the XML?

1.Suppose I have two XML\'s with one button each with same id.

2.I have

3条回答
  •  青春惊慌失措
    2020-12-03 05:07

    Android takes the easy road: IDs are not application-wide unique, but layout-wide unique.

    The value of R.id.foo is the same across two different layouts holding a control with foo id. Since they are not competing for uniqueness, it doesn't matter.

提交回复
热议问题