1

My app show a simple custom DialogFragment with a spinner and an edittext for building a model object.

I would like to ask for 2 dates (start and end) for my model, so I need 2 chained DatePickerDialog (since datepicker is too big for 2 to fit in one dialog)

Is there any convenient method to chain these dialogs ?

Dan Chaltiel
  • 7,811
  • 5
  • 47
  • 92
  • 1
    You can use datepicker view in your dialog but add scrollview or viewpager (for example, you can make in dialog button next that will switch it to second screen of dialog where datepicker will shown). – Denis Sologub Dec 10 '15 at 23:09
  • Didn't though about the viewpager, never heard about it inside a dialogfragment, I'm taking a look ! (but I thought about scrollView and don't like it in a dialog) – Dan Chaltiel Dec 10 '15 at 23:11
  • Why not?! If it will be conveniently to using when use it) But I think that it's the best way to switch pages in dialog (it maybe not only viewpage, also switchview (unfortunately, I don't remember) or that else). – Denis Sologub Dec 10 '15 at 23:20
  • I'm affraid user may not see the scroll and submit the dialog as it. Also, datpickers already have scrollviews so it would not be very convenient, and even less with two of them. – Dan Chaltiel Dec 10 '15 at 23:23
  • Sorry, HorizontalScrollView (and I advice it just like variant). I think that it's better to use viewpager (and button next on first page, so if user doesn't see that area can scroll, he will press next and dialog will switch pages). – Denis Sologub Dec 10 '15 at 23:27
  • Managed to get it working with viewpager, thanks to [this post](http://stackoverflow.com/questions/19544829/viewpager-with-fragments-inside-popupwindow-or-dialogfragment-error-no-view), but now the height of the dialog is the height of the taller fragment (and one is spinner+edit whereas others are datepickers, so it's not really pretty). So the question is still going, but you helped me a lot, thanks ! – Dan Chaltiel Dec 11 '15 at 00:14
  • You can use simple layout without fragments in viewpager. Just you not need fragment functions there. – Denis Sologub Dec 11 '15 at 00:31
  • If you don't want to dialog allocate the largest size then you need to switch layout in dialog manually without viewpager. Inflate content in root content layout in dialog and after switch it and update dialog size (Sorry, but I cannot explain it more now. You need to find it in the Internet.) – Denis Sologub Dec 11 '15 at 00:36
  • As a little hack you can try to just use FrameLayout and show and hide (gone) its top child layout! But it's dark code! :) – Denis Sologub Dec 11 '15 at 00:39

0 Answers0