Hesam
Hesam

Reputation: 53600

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.

Upvotes: 1

Views: 553

Answers (1)

5hssba
5hssba

Reputation: 8079

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..

Upvotes: 1

Related Questions