remove View On Global Layout Listener - Android User Interface

Android examples for User Interface:Layout

Description

remove View On Global Layout Listener

Demo Code


//package com.java2s;

import android.annotation.TargetApi;
import android.os.Build;
import android.view.View;
import android.view.ViewTreeObserver;

public class Main {
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public static void removeOnGlobalLayoutListener(View view,
            ViewTreeObserver.OnGlobalLayoutListener listener) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(
                    listener);//  w w  w . j  a  v  a 2s  . c  o m
        } else {
            //noinspection deprecation
            view.getViewTreeObserver().removeGlobalOnLayoutListener(
                    listener);
        }
    }
}

Related Tutorials