Go to the documentation of this file.00001 package com.introlab.rtabmap;
00002
00003 import android.content.Context;
00004 import android.preference.SwitchPreference;
00005 import android.util.AttributeSet;
00006 import android.view.View;
00007 import android.view.ViewGroup;
00008 import android.widget.Switch;
00009
00018 public class CustomSwitchPreference extends SwitchPreference {
00019
00027 public CustomSwitchPreference(Context context, AttributeSet attrs, int defStyle) {
00028 super(context, attrs, defStyle);
00029 }
00030
00037 public CustomSwitchPreference(Context context, AttributeSet attrs) {
00038 super(context, attrs);
00039 }
00040
00046 public CustomSwitchPreference(Context context) {
00047 super(context, null);
00048 }
00049
00050 @Override
00051 protected void onBindView(View view) {
00052
00053 ViewGroup viewGroup= (ViewGroup)view;
00054 clearListenerInViewGroup(viewGroup);
00055 super.onBindView(view);
00056 }
00057
00063 private void clearListenerInViewGroup(ViewGroup viewGroup) {
00064 if (null == viewGroup) {
00065 return;
00066 }
00067
00068 int count = viewGroup.getChildCount();
00069 for(int n = 0; n < count; ++n) {
00070 View childView = viewGroup.getChildAt(n);
00071 if(childView instanceof Switch) {
00072 final Switch switchView = (Switch) childView;
00073 switchView.setOnCheckedChangeListener(null);
00074 return;
00075 } else if (childView instanceof ViewGroup){
00076 ViewGroup childGroup = (ViewGroup)childView;
00077 clearListenerInViewGroup(childGroup);
00078 }
00079 }
00080 }
00081
00082 }