remove View Layout Listener - Android User Interface

Android examples for User Interface:Layout

Description

remove View Layout Listener

Demo Code


//package com.java2s;

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

public class Main {
    private static void removeLayoutListener(View view,
            ViewTreeObserver.OnGlobalLayoutListener listener) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            view.getViewTreeObserver().removeOnGlobalLayoutListener(
                    listener);//from  w  w w  . j  a va  2 s.  co m
        } else {
            //noinspection deprecation
            view.getViewTreeObserver().removeGlobalOnLayoutListener(
                    listener);
        }
    }
}

Related Tutorials