I\'m having a problem including a different layout through the include tag in the android layout xml file. When specifing the layout reference ( @layout/... ), i\'m getting
If anyone stumbles upon this thread looking for this error:
Caused by: android.view.InflateException: You must specifiy a layout in the include tag: <include layout="@layout/layoutID" />
Make sure you do:
<include layout="@layout/your_layout" />
and not:
<include android:layout="@layout/your_layout" />
layout
should not have android:
in front of it.
I've "solved" the problem, but I dont know what really helped. My layout files did not went through any major rewrite and practically contain the same. The only notable change I've done before the problem went away was to override the onMeasure( int, int ) method in my custom view class, with the implementation just calling setMeasuredDimension( 100, 100 ).
Check for empty
<include> </include>
tags, (probably caused by automatic code formatting).
They can appear somewhere 'hidden' in your xml.
For those using Xamarin Studio - I added a bunch of AXML files from a different project, and also was getting the exact same error. I simply shut down and restarted Xamarin Studio (PC) and this also solved the problem. It's interesting that a different IDE has the same issue.
launch eclipse with the -clean option and your problem is fixed guaranteed . It will take about 30 seconds longer to launch though
I don't see anything immediately wrong with that, so that's a bit odd. I can only think of two things: 1) Have you tried using a shorter file name? There are a few restrictions on what's acceptable in a file name, e.g. no uppercase characters or symbols, in order to ensure compatibility and file name length might be one of them. 2) Have you tried removing some of your android:... statements in the include, and leaving it at just <include layout="@layout/..."/>
? You don't actually need to specify its height and width in the include as that's already defined in the imported layout file.