From 299550dc0ea0ea0e5e1a8eac54d52cb34b1a40cf Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 18 Jul 2016 23:06:22 +0200 Subject: [PATCH] make sure we hide the proper field at Month picker --- .../calendar/activities/MainActivity.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java index 7209e2d9a..58bfdb621 100644 --- a/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/calendar/activities/MainActivity.java @@ -14,6 +14,7 @@ import android.view.View; import android.widget.DatePicker; import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.NumberPicker; import android.widget.TextView; import com.simplemobiletools.calendar.Calendar; @@ -186,6 +187,7 @@ public class MainActivity extends SimpleActivity implements Calendar { datePicker.init(dateTime.getYear(), dateTime.getMonthOfYear() - 1, 1, null); alertDialog.setView(view); + alertDialog.setNegativeButton("Cancel", null); alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { final int month = datePicker.getMonth() + 1; @@ -200,7 +202,10 @@ public class MainActivity extends SimpleActivity implements Calendar { private void hideDayPicker(DatePicker datePicker) { final LinearLayout ll = (LinearLayout) datePicker.getChildAt(0); final LinearLayout ll2 = (LinearLayout) ll.getChildAt(0); - ll2.getChildAt(1).setVisibility(View.GONE); + final NumberPicker picker1 = (NumberPicker) ll2.getChildAt(0); + final NumberPicker picker2 = (NumberPicker) ll2.getChildAt(1); + final NumberPicker dayPicker = (picker1.getMaxValue() > picker2.getMaxValue()) ? picker1 : picker2; + dayPicker.setVisibility(View.GONE); } @Override