0

I'm making an app that requires the user to pick a time and day of week for a recurring event. I've already implemented a TimePicker dialog, but I can't seem to find one for picking the day of the week. I've triedDatePicker, but that's only for day of month. What can I do?

johnnyRose
  • 7,310
  • 17
  • 40
  • 61
felix
  • 454
  • 9
  • 19
  • Possible duplicate: http://stackoverflow.com/questions/13966839/datepicker-selected-day-of-the-week-android – T D Nguyen Mar 09 '16 at 03:13
  • @ramedju for future reference when editing, please don't add "thanks" to the end of the post. One of the points of editing is to remove fluff, not add it. – johnnyRose Mar 09 '16 at 03:22
  • @johnnyRose I'm sorry, but I've just added it to show some courtesy for those who have exerted efforts unto the question or problem. Thanks! –  Mar 09 '16 at 07:06
  • 1
    @ramedju it's nothing to worry about. Your edits have actually been very good. Just something I had noticed. – johnnyRose Mar 09 '16 at 13:13
  • Could you just make a custom dialog with a spinner that has an Adapter pointing at a String array of Sunday-Saturday? – OneCricketeer Mar 10 '16 at 17:22
  • Alternatively, you could look at [this library](https://github.com/code-troopers/android-betterpickers) to see how the "recurrence" view is implemented. – OneCricketeer Mar 10 '16 at 17:26
  • Hi this question is already answered take a look over here: http://stackoverflow.com/questions/5270272/how-to-determine-day-of-week-by-passing-specific-date – Bali Mar 09 '16 at 03:55
  • No, i need a dialog to pick the day of the week, not retrieve the day of the week from a DatePicker dialog – felix Mar 10 '16 at 17:20
  • Thanks @cricket_007. I did end up just making a custom dialog with Sunday-Saturday – felix Mar 14 '16 at 17:29

1 Answers1

0

I you want the day of week you will have use SimpleDateFormat and use EEEE for example.

  public void onDateSet(DatePicker view, int selectedYear,
        int selectedMonth, int selectedDay) 
    {   
      SimpleDateFormat dateformat = new SimpleDateFormat("EEEE");
      Date date = new Date(selectedYear, selectedMonth, selectedDay-1);
      String dayOfWeek = dateformat.format(date);
    }
Sumanth Jois
  • 3,146
  • 4
  • 27
  • 42
  • I think you misunderstood the question. They want a Dialog to pick the day of the week, not format a string – OneCricketeer Mar 09 '16 at 03:26
  • @cricket_007 you are right, I need a dialogue to pick the day of the week. – felix Mar 10 '16 at 17:19
  • if you want a Dialog just create a custom Dialog which extends DialogFragment.and override the onDateSet method like i did in the above. if this was helpfull don't forget to tick the answer. Thankyou – Sumanth Jois Mar 11 '16 at 01:55