@Override public void visitElement(Context context, Element element) { int childCount = LintUtils.getChildCount(element); String tagName = element.getTagName(); if (tagName.equals(SCROLL_VIEW) || tagName.equals(HORIZONTAL_SCROLL_VIEW)) { if (childCount > 1 && getAccurateChildCount(element) > 1) { context.client.report(context, SCROLLVIEW_ISSUE, context.getLocation(element), "A scroll view can have only one child", null); } } else { // Adapter view if (childCount > 0 && getAccurateChildCount(element) > 0) { context.client.report(context, ADAPTERVIEW_ISSUE, context.getLocation(element), "A list/grid should have no children declared in XML", null); } } }
@Override public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int childCount = LintUtils.getChildCount(element); String tagName = element.getTagName(); if (tagName.equals(SCROLL_VIEW) || tagName.equals(HORIZONTAL_SCROLL_VIEW)) { if (childCount > 1 && getAccurateChildCount(element) > 1) { context.report(SCROLLVIEW_ISSUE, element, context.getLocation(element), "A scroll view can have only one child"); } } else { // Adapter view if (childCount > 0 && getAccurateChildCount(element) > 0) { context.report(ADAPTER_VIEW_ISSUE, element, context.getLocation(element), "A list/grid should have no children declared in XML"); } } }
@Override public void visitElement(@NonNull XmlContext context, @NonNull Element element) { int childCount = LintUtils.getChildCount(element); String tagName = element.getTagName(); if (tagName.equals(SCROLL_VIEW) || tagName.equals(HORIZONTAL_SCROLL_VIEW)) { if (childCount > 1 && getAccurateChildCount(element) > 1) { context.report(SCROLLVIEW_ISSUE, element, context.getLocation(element), "A scroll view can have only one child"); } } else { // Adapter view if (childCount > 0 && getAccurateChildCount(element) > 0) { context.report(ADAPTER_VIEW_ISSUE, element, context.getLocation(element), "A list/grid should have no children declared in XML"); } } }