MaterialDateTimePicker

a2dcore

New Member
Licensed User
I've got this java code working:

B4X:
public Calendar[] getValidDays(Long nbDate, Long neDate, String[] lsHoli) {
    Date begDate = new Date(nbDate);
    Date endDate = new Date(neDate);

    Calendar begCal = Calendar.getInstance();
    Calendar endCal = Calendar.getInstance();
   
    begCal.setTime(begDate);
    endCal.setTime(endDate);
   
    LinkedList<Calendar> daysList= new LinkedList<Calendar>();
    Calendar[] daysArray;

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String dtStr = null;
    List<String> dayHoli = Arrays.asList(lsHoli);
   
    while ( begCal.getTimeInMillis() <= endCal.getTimeInMillis()) {
       if (begCal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
       
            dtStr = sdf.format(begCal.getTime());
            if (!dayHoli.contains(dtStr)) {
                Calendar c = Calendar.getInstance();
               c.setTimeInMillis(begCal.getTimeInMillis());
               daysList.add(c);
            }
       }
        begCal.setTimeInMillis(begCal.getTimeInMillis() + (24*60*60*1000));
    }
   
    daysArray = new Calendar[daysList.size()];
    for (int i = 0; i < daysArray.length ; i++)
    {
       daysArray[i] = daysList.get(i);
    }
    return daysArray;
}

Usage:

B4X:
dpDate.SelectableDays = nativeMe.RunMethod("getValidDays", Array(minDate, maxDate, lstHolidays))
 

Marc De Loose

Member
Licensed User
Longtime User
I get this when trying to build your example:

B4X:
Generating R file.    Error
C:\Users\Marc\Documents\0_ELECTRONICS 2017\2017 Android development\MaterialDateTimePicker\Objects\bin\extra\res1\res\layout\mdtp_date_time_picker_dialog.xml:10: error: No resource identifier found for attribute 'layout_scrollFlags' in package 'b4a.example'
C:\Users\Marc\Documents\0_ELECTRONICS 2017\2017 Android development\MaterialDateTimePicker\Objects\bin\extra\res1\res\layout\mdtp_date_time_picker_dialog.xml:16: error: No resource identifier found for attribute 'layout_behavior' in package 'b4a.example'
C:\Users\Marc\Documents\0_ELECTRONICS 2017\2017 Android development\MaterialDateTimePicker\Objects\bin\extra\res1\res\layout\mdtp_date_time_picker_dialog.xml:16: error: Error: No resource found that matches the given name (at 'layout_behavior' with value '@string/appbar_scrolling_view_behavior').

Adter adding the line: #AdditionalJar: com.android.support:design

I only get this error:
B4X:
B4A version: 7.01
Parsing code.    (0.00s)
Compiling code.    (0.04s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Generating R file.    Error
invalid resource directory name: C:\Users\Marc\Documents\0_ELECTRONICS 2017\2017 Android development\MaterialDateTimePicker\Objects\bin\extra\res3\res/values-b+sr+Latn

I am using v1.7 of the library and tied JAR 23 and 26.

I am lost
 
Last edited:

bl4ck4nt

Member
Licensed User
Longtime User

Try add this
B4X:
#AdditionalJar: com.android.support:design
 

Pencil3

Member
Licensed User
Is it possible to set the MinDate to 01-01-2017 but have today's date selected when the dialog is selected?

For example when using the below when the dialog is selected the date of Jan 01 2017 is selected, I would like today's date to be selected and still be able to select a date back until 01-01-2017.

B4X:
cal.Initialize("mm-dd-yyyy",cal.US,"01-01-2017")
 

DonManfred

Expert
Licensed User
Longtime User
This is my code from the example.
It is using V1.7 and it does not raise an unknown member error.

B4X:
    Activity.LoadLayout("Layout1")
    time.Initialize("Time",13,0,True)
    date.Initialize("Date",2017,8,31)
    Log(DateTime.DeviceDefaultTimeFormat)
   
   
    Dim cal As Calendar
    cal.Initialize("dd.mm.yyyy",cal.GERMAN,"1.1.2017")
   
    date.MinDate = cal
 

Pencil3

Member
Licensed User
In your example you use date.MinDate, you said to try cal.MinDate and that is when I receive unknown member: mindate error.

For my date.Initialize I am already using it for a DateTime.Now or I would use it per your example.

All I would like to do is when selecting the picker is have today's date selected and still be able to select a previous date to today's date.

If I use:

B4X:
Dim cal As Calendar
        cal.Initialize("mm-dd-yyyy",cal.US,"")
        date.MinDate = cal

Today's date is selected, but I can not choose a date prior to today's date.

 

mcqueccu

Well-Known Member
Licensed User
Longtime User
i think you must asume month -1 or so. Something like that i have in mind...
0-11 are the returning months....
I have used (Month +1) So that it returns a (library return month +1) .Got lil confused looking at the library Example. Thank you for this great library.It could be easy if it returns Range 1- 12 though.
Best Regards...
 

mcqueccu

Well-Known Member
Licensed User
Longtime User
yes, if i have the source... I do not have the source anymore; i lost all my sources a few minths ago. Don´t expect to get any new version.
Sorry to hear about that.Worst cases we face
Its big thing that it was wrapped n worked properly as expected we can use it.

Small Request
Dear Don i m learning wrapping library too and wrapped some of the library u have did here in forum for practicing it going well,But couldn't wrap the library with these types of dialog.It could be very helpful if you could share some part of it so we could learn too.

Best Regards...
 

trueboss323

Active Member
Licensed User
Longtime User
I am unfortunately still having that No Resource Found error. I'm using your latest library (1.7) and B4A version 7.30 , I've tried changing the SDK to 25, 24,23,21 but it didn't help
 

DonManfred

Expert
Licensed User
Longtime User
Requesting latest wraps similar to those projects.
I have not any library similar to this. This library is one of around 50 libs i tried to wrap two years ago. ALL unsuccessfully exept this one. and all the sources are lost.

I´ve put it on my TODO list to rewrite the lib some day
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…