restore View Touch Delegate - Android User Interface

Android examples for User Interface:Touch Event

Description

restore View Touch Delegate

Demo Code


//package com.java2s;
import android.graphics.Rect;
import android.view.TouchDelegate;
import android.view.View;

public class Main {

    public static void restoreViewTouchDelegate(final View view) {

        ((View) view.getParent()).post(new Runnable() {
            @Override/*from  w  w  w  .ja  v a2 s . c o m*/
            public void run() {
                Rect bounds = new Rect();
                bounds.setEmpty();
                TouchDelegate touchDelegate = new TouchDelegate(bounds,
                        view);

                if (View.class.isInstance(view.getParent())) {
                    ((View) view.getParent())
                            .setTouchDelegate(touchDelegate);
                }
            }
        });
    }
}

Related Tutorials