Android examples for android.app:Activity Property
get Activity from ViewParent
import android.app.Activity; import android.view.ViewParent; public class Main{ /**//from w w w. ja va 2 s . c o m * Return the {@link Activity} of {@link ViewParent}. * * @param parent * @return */ public final static Activity getActivity(ViewParent parent) { if (parent instanceof Activity) { return (Activity) parent; } if (parent.getParent() != null) { return getActivity(parent.getParent()); } return null; } }