@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void initialisePaging(View view) { datePickers = new Vector<>(); FrameLayout fl1 = new FrameLayout(getActivity()); FrameLayout fl2 = new FrameLayout(getActivity()); startDatePicker = new DatePicker(getActivity()); startDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); endDatePicker = new DatePicker(getActivity()); endDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // not entirely necessary since this feature will never be supported // below Honeycomb if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { startDatePicker.setCalendarViewShown(false); endDatePicker.setCalendarViewShown(false); } fl1.addView(startDatePicker); fl1.setTag("Start Date"); fl2.addView(endDatePicker); fl2.setTag("End Date"); datePickers.add(fl1); datePickers.add(fl2); ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers); WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager); pager.setPageMargin(2); pager.setAdapter(adapter); TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles); tabIndicator.setViewPager(pager); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void initialisePaging(View view) { datePickers = new Vector<View>(); FrameLayout fl1 = new FrameLayout(getSherlockActivity()); FrameLayout fl2 = new FrameLayout(getSherlockActivity()); startDatePicker = new DatePicker(getSherlockActivity()); startDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); endDatePicker = new DatePicker(getSherlockActivity()); endDatePicker.setLayoutParams( new FrameLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, Gravity.CENTER)); // this is always true for now, but not so when I get 2.x implemented if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { startDatePicker.setCalendarViewShown(false); endDatePicker.setCalendarViewShown(false); } fl1.addView(startDatePicker); fl1.setTag("Start Date"); fl2.addView(endDatePicker); fl2.setTag("End Date"); datePickers.add(fl1); datePickers.add(fl2); ViewPagerAdapter adapter = new ViewPagerAdapter(datePickers); WrappedViewPager pager = (WrappedViewPager) view.findViewById(R.id.wrappedviewpager); pager.setPageMargin(2); pager.setAdapter(adapter); TabPageIndicator tabIndicator = (TabPageIndicator) view.findViewById(R.id.titles); tabIndicator.setViewPager(pager); }