Can I use the same id in different layout in Android?

前端 未结 4 1245
醉话见心
醉话见心 2020-12-07 19:37

I am new to Android development. Is it fine to use the same ID for images and TextViews in different Layout XML files?

When eclipse auto-li

4条回答
  •  春和景丽
    2020-12-07 20:21

    According to developer API guides:

    An ID need not be unique throughout the entire tree, but it should be unique within the part of the tree you are searching (which may often be the entire tree, so it's best to be completely unique when possible).

    So the short answer is that it's not mandatory but it's a good practice to avoid possible conflicts.

提交回复
热议问题