I\'m trying to write a custom compound view composed by a TextView
and an EditText
, _compound_view.xml_:
The issue is happening because of the id
field on compound_view.xml
From your code, I just noticed that you inflated compound_view
layout file in CompoundView
class.
As soon as you create compound_view.xml
and put android:id="@+id/textLabel"
and android:id="@+id/textEdit"
id in your layout xml
file, android studio automatically create those id
s into int
values in R
class for single time.
So, when you put CompoundView
twice time in your activity_main.xml
layout file, you just creating two instance of CompoundView
but, both instances textEdit
and textLabel
have only 1 address location for each one. So, they are pointing to same address locations which are declared in R
class.
That's why, whenever you change textEdit
or textLabel
text programatically, they also change other textEdit
or textLabel
which are presented in both of your CompoundView