clean Up View On Click Listeners - Android User Interface

Android examples for User Interface:View Click

Description

clean Up View On Click Listeners

Demo Code


//package com.java2s;

import android.view.View;

import android.widget.AdapterView;

public class Main {

    @SuppressWarnings({ "rawtypes" })
    private static void cleanUpOnClickListeners(View view) {
        if (view instanceof AdapterView) {
            ((AdapterView) view).setOnItemClickListener(null);
            ((AdapterView) view).setOnItemLongClickListener(null);
            ((AdapterView) view).setOnItemSelectedListener(null);
        } else {/*from   w  ww. j a  v a 2  s  .c  om*/
            view.setOnClickListener(null);
            view.setOnLongClickListener(null);
            view.setOnTouchListener(null);
        }
    }
}

Related Tutorials