Skip to main content
Rollback to Revision 3 - Edit approval overridden by post owner or moderator
Source Link
Ron Ziroby Romero
  • 9.5k
  • 8
  • 46
  • 67

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

in Java:

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

or in Kotlin:

val test1TextView = test1.text 

Using that approach, you can access any field in any include you have.

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

in Java:

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

or in Kotlin:

val test1TextView = test1.text 

Using that approach, you can access any field in any include you have.

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

Using that approach, you can access any field in any include you have.

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

in Java:

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

or in Kotlin:

val test1TextView = test1.text 

Using that approach, you can access any field in any include you have.

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

Using that approach, you can access any field in any include you have.

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

in Java:

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

or in Kotlin:

val test1TextView = test1.text 

Using that approach, you can access any field in any include you have.

Rollback to Revision 1
Source Link
Ron Ziroby Romero
  • 9.5k
  • 8
  • 46
  • 67

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

Using that approach, you can access any field in any include you have.

Edit:

@Zlatko: "If the layout that us included is using merge, this will not help. But in case where merge is not used, this works."

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

Using that approach, you can access any field in any include you have.

Edit:

@Zlatko: "If the layout that us included is using merge, this will not help. But in case where merge is not used, this works."

Specify the ID in the <include>

<include layout="@layout/test" android:id="@+id/test1" /> 

Then use two findViewById to access fields in the layout

View test1View = findViewById(R.id.test1); TextView test1TextView = (TextView) test1View.findViewById(R.id.text); 

Using that approach, you can access any field in any include you have.

added 131 characters in body
Source Link
Bob
  • 23.1k
  • 41
  • 147
  • 230
Loading
Source Link
Ron Ziroby Romero
  • 9.5k
  • 8
  • 46
  • 67
Loading