Invalidates a view and all of its descendants. - Android User Interface

Android examples for User Interface:View

Description

Invalidates a view and all of its descendants.

Demo Code

// Copyright 2015 The Chromium Authors. All rights reserved.
//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {
    /**//from   w  w  w. j a  v a  2s.  c  o  m
     * Invalidates a view and all of its descendants.
     */
    private static void recursiveInvalidate(View view) {
        view.invalidate();
        if (view instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) view;
            int childCount = group.getChildCount();
            for (int i = 0; i < childCount; i++) {
                View child = group.getChildAt(i);
                if (child.getVisibility() == View.VISIBLE) {
                    recursiveInvalidate(child);
                }
            }
        }
    }
}

Related Tutorials