Skip to main content
added 1 characters in body
Source Link
Lucifer
  • 29.7k
  • 25
  • 93
  • 144

In my layout xml file, I have included other layout xml file (each with a different android id).

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

But when I run it in the emulator, and start Hierarchy Viewer, each of the layout still shows 'NO_ID', and in my code, I have findViewById(R.id.test1)findViewById(R.id.test1) and findViewById(R.id.test2)findViewById(R.id.test2) both returns null.

Can anyone please help me with my problem  ? Thank you.

In my layout xml file, I have included other layout xml file (each with a different android id).

 

But when I run it in the emulator, and start Hierarchy Viewer, each of the layout still shows 'NO_ID', and in my code, I have findViewById(R.id.test1) and findViewById(R.id.test2) both returns null.

Can anyone please help me with my problem? Thank you.

In my layout xml file, I have included other layout xml file (each with a different android id).

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

But when I run it in the emulator, and start Hierarchy Viewer, each of the layout still shows 'NO_ID', and in my code, I have findViewById(R.id.test1) and findViewById(R.id.test2) both returns null.

Can anyone please help me with my problem  ?

Source Link
hap497
  • 164.7k
  • 43
  • 86
  • 103

How to specify id when uses include in layout xml file

In my layout xml file, I have included other layout xml file (each with a different android id).

But when I run it in the emulator, and start Hierarchy Viewer, each of the layout still shows 'NO_ID', and in my code, I have findViewById(R.id.test1) and findViewById(R.id.test2) both returns null.

Can anyone please help me with my problem? Thank you.