简体   繁体   中英

Android, Can we have repeated ids in different xml file for views?

Assume that we have 3 different activities. Each activity has its own XML file for drawing UI. In each XML file we have a TextView (but style of each one is different with the others).

I want to know what will happen if i assign same id to each of them for example android:id = "@+id/textView" for all of them.

When you use setContentView(R.layout.yourlayout); the findViewById() will get the textview from that particular layout only...so you can assign same ids in different activities..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM