I have two different layouts for two different Activities. There is a button in each of these layouts with the same id: \"@+id/btnOK\". When I set a property for one of thes
To me it looks all right (and sometimes quite natural) to use duplicate ids, as long as you do it correctly: instead of Activity.findViewById() which always returns the first matching view, use ViewGroup.findViewById() (ViewGroup can be LinearLayout, FrameLayout etc) which returns view withing the view group.
To avoid lint warnings:
(Preferred) Place content of the ViewGroup in separate layout XML and use
This way you can have several includes of same layout with different parent ids (but same child ids) and lint will never complain.
Disable Lint warning for the project by unticking the box "Duplicate ids within a single layout" in *Settings/Editor/Inspections*