[Solved] Creating id for Android Views


if it is right to reference the TextView in both the XML files with same id?

It is totally fine, the compiler will only look at the ID under a single view hierarchy.

e.g.: findViewById(R.id.textview) inside ActivityA.java will only search for textview ID inside activity_a.xml (assuming you have setContentView(R.layout.activity_a); beforehand.

what is the recommended way to name a View in Android?

In my opinion, you just need to be consistent in naming your view throughout the app. The main goal is to avoid misinterpretation and confusion.

Hope it helps!

solved Creating id for Android Views