index Of View In Parent - Android User Interface

Android examples for User Interface:View Parent

Description

index Of View In Parent

Demo Code


//package com.java2s;

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

public class Main {
    public static int indexOfViewInParent(View view, ViewGroup parent) {
        int index;
        for (index = 0; index < parent.getChildCount(); index++) {
            if (parent.getChildAt(index) == view)
                break;
        }//from ww  w  . j  a v a2  s .co  m
        return index;
    }
}

Related Tutorials