On switch change the views in the repeat layout change
[unical.git] / src / ro / ieval / unical / TrivialFragment.java
index 727814ae85dd6e45ddafe3df7719ea0e978f50e2..3de4ed48ece35316ce24b5408f04a3e394d50925 100644 (file)
@@ -5,15 +5,36 @@ import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
+import android.widget.CompoundButton;
+import android.widget.LinearLayout;
+import android.widget.Spinner;
+import android.widget.Switch;
+import android.widget.CompoundButton.OnCheckedChangeListener;
 
 public final class TrivialFragment extends Fragment {
-       private final int layout;
-       public TrivialFragment(final int layout){
-               this.layout=layout;
-       }
+       public static final String ARGUMENT_LAYOUT="layout";
 
        @Override
     public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
-        return inflater.inflate(layout, container, false);
-    }
+               
+               final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false);
+               final LinearLayout ll = (LinearLayout) view.findViewById(R.id.repeat_layout);
+               
+               if(ll != null){
+                       final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch);
+                       Utils.setEnabledRecursively(ll, false);
+                       
+                       repeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
+                               @Override
+                               public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) {
+                                       if(isChecked) {
+                                               Utils.setEnabledRecursively(ll, true);
+                                       }else {
+                                               Utils.setEnabledRecursively(ll, false);
+                                       }
+                               }
+                       });
+               }
+               return view;
+       }
 }
This page took 0.010205 seconds and 4 git commands to generate.