Android examples for User Interface:View Click
Add On Long Click Binder to View recursively
//package com.java2s; import android.view.View; import android.view.ViewGroup; public class Main { public static void deepOnLongClickBinder(View view, View.OnLongClickListener listener) { if (view == null) { return; }//from www. j a v a 2 s . c o m view.setOnLongClickListener(listener); if (view instanceof ViewGroup) { for (int i = 0; i < ((ViewGroup) view).getChildCount(); ++i) { View v = ((ViewGroup) view).getChildAt(i); if (v instanceof ViewGroup) { deepOnLongClickBinder(v, listener); } else { v.setOnLongClickListener(listener); } } } } }