Here you can find the source of findInParents(View view, Class> parentClass)
public static ViewParent findInParents(View view, Class<?> parentClass)
//package com.java2s; import android.view.View; import android.view.ViewParent; public class Main { public static ViewParent findInParents(View view, Class<?> parentClass) { ViewParent par = view.getParent(); while (par != null) { if (parentClass.isAssignableFrom(par.getClass())) return par; par = par.getParent();/*from w w w . j a v a2s . c o m*/ } return null; } }