From: Petru Trimbitas Date: Wed, 12 Jun 2013 17:21:27 +0000 (+0300) Subject: On switch change the views in the repeat layout change X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=361c6a289ebad738be848ce8db42b40428600891;p=unical.git On switch change the views in the repeat layout change --- diff --git a/res/layout/add_event_basic_tab.xml b/res/layout/add_event_basic_tab.xml index aca5e87..1f7ea5d 100644 --- a/res/layout/add_event_basic_tab.xml +++ b/res/layout/add_event_basic_tab.xml @@ -104,52 +104,58 @@ - + + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + diff --git a/src/ro/ieval/unical/TrivialFragment.java b/src/ro/ieval/unical/TrivialFragment.java index 0932a4a..3de4ed4 100644 --- a/src/ro/ieval/unical/TrivialFragment.java +++ b/src/ro/ieval/unical/TrivialFragment.java @@ -6,6 +6,7 @@ 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; @@ -15,17 +16,21 @@ public final class TrivialFragment extends Fragment { @Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { + final View view=inflater.inflate(getArguments().getInt(ARGUMENT_LAYOUT), container, false); - final Switch repeatSwitch = (Switch) view.findViewById(R.id.repeat_switch); - if(repeatSwitch != null){ - final Spinner repeatSpinner = (Spinner) view.findViewById(R.id.repeat_spinner); + 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) { - repeatSpinner.setEnabled(true); + Utils.setEnabledRecursively(ll, true); }else { - repeatSpinner.setEnabled(false); + Utils.setEnabledRecursively(ll, false); } } }); diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java index b163434..74fa1a2 100644 --- a/src/ro/ieval/unical/Utils.java +++ b/src/ro/ieval/unical/Utils.java @@ -4,7 +4,7 @@ import android.view.View; import android.view.ViewGroup; final class Utils { - public void setEnabledRecursively(final View view, final boolean enabled){ + public static void setEnabledRecursively(final View view, final boolean enabled){ view.setEnabled(enabled); if(view instanceof ViewGroup){ final ViewGroup group=(ViewGroup) view;