From dd56622d6d290050e5fc67055be2e0ac5267bd6f Mon Sep 17 00:00:00 2001 From: Benjamin Durin Date: Wed, 30 Oct 2013 12:44:24 +0800 Subject: [PATCH] DatePicker works in landscape mode for Android --- .../functoins/DatePickerDialogContext.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ANDROID/src/pl/mateuszmackowiak/nativeANE/functoins/DatePickerDialogContext.java b/ANDROID/src/pl/mateuszmackowiak/nativeANE/functoins/DatePickerDialogContext.java index 83ae8c6..9e995ae 100644 --- a/ANDROID/src/pl/mateuszmackowiak/nativeANE/functoins/DatePickerDialogContext.java +++ b/ANDROID/src/pl/mateuszmackowiak/nativeANE/functoins/DatePickerDialogContext.java @@ -12,6 +12,7 @@ import android.app.TimePickerDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.res.Configuration; import android.text.Html; import android.util.Log; import android.view.Gravity; @@ -22,7 +23,6 @@ import android.widget.DatePicker; import android.widget.DatePicker.OnDateChangedListener; import android.widget.LinearLayout; -import android.widget.RelativeLayout; import android.widget.TimePicker; import android.widget.TimePicker.OnTimeChangedListener; @@ -434,26 +434,27 @@ public TimeAndDatePicker(FREContext freContext,Context context, int year, int mo public void createContent(FREContext freContext,Context context, int year, int monthOfYear, int dayOfMonth, int hourOfDay, int minute,boolean is24HourView, boolean hasMinMax, long minDate, long maxDate, int theme) { - RelativeLayout rl = new RelativeLayout(context); - LinearLayout ll = new LinearLayout(context); - ll.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); - ll.setOrientation(LinearLayout.VERTICAL); + ll.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + ll.setPadding(0, 0, 0, 5); + if (freContext.getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) + ll.setOrientation(LinearLayout.HORIZONTAL); + else + ll.setOrientation(LinearLayout.VERTICAL); ll.setGravity(Gravity.CENTER_HORIZONTAL); + datePicker = new DatePicker(context); + datePicker.init(year, monthOfYear, dayOfMonth, new MyOnDateChangeListenr(freContext , hasMinMax, minDate, maxDate)); + ll.addView(datePicker); + timePicker = new TimePicker(context); + timePicker.setIs24HourView(is24HourView); timePicker.setCurrentHour(hourOfDay); timePicker.setCurrentMinute(minute); - timePicker.setIs24HourView(is24HourView); timePicker.setOnTimeChangedListener(new MyOnTimeChangeListener(freContext)); ll.addView(timePicker); - datePicker = new DatePicker(context); - datePicker.init(year, monthOfYear, dayOfMonth, new MyOnDateChangeListenr(freContext , hasMinMax, minDate, maxDate)); - ll.addView(datePicker); - - rl.addView(ll); - setView(rl); + setView(ll); } public TimePicker getTimePicker(){