Java tutorial
//package com.java2s; //License from project: Open Source License import android.view.View; import android.view.ViewGroup; public class Main { public static ViewGroup getParent(View v, int parentId) { ViewGroup p = (ViewGroup) v.getParent(); while (true) { if (p == null) { return null; } if (p.getId() == parentId) { return p; } p = (ViewGroup) p.getParent(); } } }