Home > Mobile >  Questions about the include other layout in XML
Questions about the include other layout in XML

Time:09-24

I found the referenced control the layout of the id and the original layout id cannot be consistent, otherwise the back doesn't work,
For example, I in the main XML cited
The android: id="@ + id/l2"
Android: layout_width="wrap_content"
Android: layout_height="wrap_content"
Android: layout_marginTop="45 dp"
Layout="@ layout/ano"/& gt;
In ano. There is for the XML, and my main. XML has for the inside, only the front for the work, later use an item, so if you want to reference other layout, not to put other layout look again, see if there are any conflict of id? If the project reference layout more, it's too easy to conflict

CodePudding user response:

1. Different layout controls id should be well yourself to distinguish
2. View. The findViewById () should be able to solve

CodePudding user response:

Id don't repeat! Don't repeat! Don't repeat!
Why the writing the same? Very easy to make a mistake to confuse, looking for a particular trouble,
A new version of Android if repeat will be an error in the Studio,

CodePudding user response:

refer to the second floor can reply wang:
id don't repeat! Don't repeat! Don't repeat!
Why the writing the same? Very easy to make a mistake to confuse, looking for a particular trouble,
A new version of Android if repeat will be an error in the Studio,

I don't write the id of the repeated in different XML, and then an XML cited another XML

CodePudding user response:

As if not, also could be useless for me

CodePudding user response:

I think you should look at alibaba Android development manual Android resource file name, id is not to take, must have the specification, naturally you won't get your this little problem

CodePudding user response:

Distinguish ID,,,

CodePudding user response:

His name is not standard, oneself all don't know what it is, in a few days you go people are fog didn't know you write of what

CodePudding user response:

Well, I want to understand, the question is whether it is directly defined or reference other XML, and in other XML defined, at least in an XML is the only, named do specifications

CodePudding user response:

You this kind of question is actually naming problems, such as I will be named after main_xxx in layout_main named, so as not to cause conflict
  • Related