clear All Edits from ViewGroup - Android User Interface

Android examples for User Interface:ViewGroup

Description

clear All Edits from ViewGroup

Demo Code


//package com.java2s;

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

import android.widget.EditText;
import android.widget.LinearLayout;

public class Main {
    public static void clearAllEdits(ViewGroup group) {
        if (group != null) {
            int count = group.getChildCount();
            for (int i = 0; i < count; ++i) {
                View view = group.getChildAt(i);
                if (view instanceof EditText) {
                    ((EditText) view).setText("");
                } else if (view instanceof LinearLayout) {
                    clearAllEdits((ViewGroup) view);
                }//from   www .  ja  v  a  2s. c o m
            }
        }
    }
}

Related Tutorials