Using Kotin android extensions I can avoid using findViewById
, but
Im not sure how to name the ids to use it propertly.
I found two options are:
- Use simple names for ids but then I can get in trouble with espresso if I use it with fragments:
android.support.test.espresso.AmbiguousViewMatcherException: 'with id: .../mainLayout' matches multiple views in the hierarchy.
It is because I have two fragments inside a TabLayout with same ids:
<LinearLayout android:id="@+id/mainLayout"
- Name with owner:
"@+id/loginMainLayout"
and"@+id/signUpMainLayout"
But then I will have to use variables like signUpMainLayout.doSomething()
.
Note: I dont like the use of
_
in this case since that's not a good code style.
What other options are?