]> iEval git - unical.git/commitdiff
On switch change the views in the repeat layout change
authorPetru Trimbitas <l3asketballplayer@yahoo.com>
Wed, 12 Jun 2013 17:21:27 +0000 (20:21 +0300)
committerPetru Trimbitas <l3asketballplayer@yahoo.com>
Wed, 12 Jun 2013 17:21:27 +0000 (20:21 +0300)
res/layout/add_event_basic_tab.xml
src/ro/ieval/unical/TrivialFragment.java
src/ro/ieval/unical/Utils.java

index aca5e874787c1a1fd4e765122e3a6eb8bc12c2f2..1f7ea5d6c0be86a1f0f11b95a3725ebd9e198495 100644 (file)
 
     </LinearLayout>
 
-    <Spinner
-        android:id="@+id/repeat_spinner"
-        android:entries="@array/repeat_array"
-        android:layout_width="match_parent"
+       <LinearLayout
+           android:layout_width="match_parent"
         android:layout_height="wrap_content"
+        android:id="@+id/repeat_layout"
+        android:orientation="vertical" >
+        
+           <Spinner
+               android:id="@+id/repeat_spinner"
+               android:entries="@array/repeat_array"
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content"
          />
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" >
-
-        <TextView
-            android:id="@+id/textView1"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/repeat_every"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-
-        <EditText
-            android:id="@+id/editText1"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_weight="1"
-            android:ems="10"
-            android:inputType="number" />
-
-        <TextView
-            android:id="@+id/textView2"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="Medium Text"
-            android:textAppearance="?android:attr/textAppearanceMedium" />
-
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content" >
-
-        <Spinner
-            android:id="@+id/repeat_type"
-            android:entries="@array/repeat_type_array"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_weight="1" />
-
-    </LinearLayout>
-
+           
+           <LinearLayout
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content" >
+       
+               <TextView
+                   android:id="@+id/textView1"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="@string/repeat_every"
+                   android:textAppearance="?android:attr/textAppearanceMedium" />
+       
+               <EditText
+                   android:id="@+id/editText1"
+                   android:layout_width="0dip"
+                   android:layout_height="wrap_content"
+                   android:layout_weight="1"
+                   android:ems="10"
+                   android:inputType="number" />
+       
+               <TextView
+                   android:id="@+id/textView2"
+                   android:layout_width="wrap_content"
+                   android:layout_height="wrap_content"
+                   android:text="Medium Text"
+                   android:textAppearance="?android:attr/textAppearanceMedium" />
+       
+           </LinearLayout>
+       
+           <LinearLayout
+               android:layout_width="match_parent"
+               android:layout_height="wrap_content" >
+       
+               <Spinner
+                   android:id="@+id/repeat_type"
+                   android:entries="@array/repeat_type_array"
+                   android:layout_width="0dip"
+                   android:layout_height="wrap_content"
+                   android:layout_weight="1" />
+       
+           </LinearLayout>
+       </LinearLayout>
 </LinearLayout>
index 0932a4a727843e26076b2e45f5bf62a6d1467cb2..3de4ed48ece35316ce24b5408f04a3e394d50925 100644 (file)
@@ -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);
                                        }
                                }
                        });
index b163434f9b28428ad43d41a885d3728a9c3c7601..74fa1a2371cacea31bc46ff632928aac24e1a046 100644 (file)
@@ -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;
This page took 0.038547 seconds and 4 git commands to generate.