How to access to view using kotlin synthetic extension if I have a layout like below:
文件:Two_day_view.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/day1"
layout="@layout/day_row"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
android:id="@+id/day2"
layout="@layout/day_row"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
文件:day_row.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/dayName"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
如何访问dayName?我找了一些这样的:
day1.dayName.text = "xxx"
day2.dayName.text = "sss"
我在Studio中看到我可以访问dayName
,但dayName TextView指的是哪一个?
Normal if I have only one included layout it works fine. But now I have multiple times included same layout.
of course I can always do:
day1.findViewById(R.id.dayName).text = "xxx"
but I'm looking for nice solution. :)