get Parent View - Android User Interface

Android examples for User Interface:View Parent

Description

get Parent View

Demo Code


//package com.java2s;

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

public class Main {
    public static <T extends ViewGroup> T getParent(View v) {
        ViewParent parent = v.getParent();
        if (parent == null || !(parent instanceof ViewGroup))
            return null;
        return (T) parent;
    }/*w ww  . ja v a2 s.  co  m*/
}

Related Tutorials