I have a tabhost in my app defined by code. Besides this, I have a Panel defined by code too. In activity_create, I'm trying to load a layout with seven buttons, all of them created with the designer.
Are you sure that you have added all 7 buttons to the "activity" in the designer. If you have added them to a panel then the number returned will be different.
Anyway you shouldn't use NumberOfViews.
Instead iterate over all views with:
B4X:
For Each v As View In Panel.GetAllViewsRecursive
Next