Skip to first unread message

Sten Jensby

unread,
Jun 9, 2018, 4:56:40 AM6/9/18
to MIT App Inventor Forum
Hi

Have 42 buttons arranged like a calender 7 by 6
If first day of month is friday (weekday6) i need to change the text on button to 1.
and for the remaining buttons, so i get a "calendar" 
But i will need som kind of array or loop. 

For button1 to button42 do the following 
check if button1 = first day of month. , if not then button1 is hiding
if button2 = first day of month, write text "1" on button2 text and proceeed to next button 
Ect.

so i will end up with ex 30 visible buttons from 1 to 30, that i can click on.

Any help

Chris Ward

unread,
Jun 9, 2018, 5:22:35 AM6/9/18
to MIT App Inventor Forum
Hi Sten

That is a lot of buttons, smart phone screens are small and the buttons need to be big for ease of use. Unless there is an outstanding reason not to, I recommend using the built-in DatePicker. It is what 99% of Android Users will expect to see.......

Sten Jensby

unread,
Jun 9, 2018, 5:29:17 AM6/9/18
to MIT App Inventor Forum
I am the last 1 %......

Date picker is not what i need, and the app is for my only. size of buttons and layout is ok for me.
I need a calander function weekly shown, 
4 -5 weeks at a time, ( month).
If something is true in some days, the backcolor should be changing to that, but that's a later issue,

Making arrays ect is easy in windowsprogramming, so i think it should be easy here also.

Chris Ward

unread,
Jun 9, 2018, 5:45:24 AM6/9/18
to MIT App Inventor Forum
Hi Sten

.... except that App Inventor does not have arrays as such, only "lists".

So, need to be comparing number of day of the week (1 to 7), where button 1 would represent either Sunday or Monday, depending on Country/Region/Locale, with number of the 1st day of the Month, then label accordingly from there.

This is going to require a large coffee.....

Chris Ward

unread,
Jun 9, 2018, 6:09:55 AM6/9/18
to MIT App Inventor Forum
... you could use an HTML Calendar in an App Inventor WebView Component (HTML files can be stored on the device).

There is also at least one extension (App Inventor plug-in) that delivers a Calendar:



Chris Ward

unread,
Jun 9, 2018, 10:14:50 AM6/9/18
to MIT App Inventor Forum
Hi again Sten

See the attached Project file, which essentially does as you require with App Inventor components:

1) Best not to hide buttons, because the others will then shuffle along and spoil your layout. Leave them blank instead.
2) In my example, I have not laid-out the buttons in a 7 x 6 format, that's your job :)
3) I have saved you the time of making the ListBlocks which I can do quickly here with the help of a util.
4) I have set February to default to 29 days (ListDaysPerMonth). You will need to check for a leap year.

regards
Chris
Calendar.aia

Abraham Getzler

unread,
Jun 10, 2018, 3:10:01 PM6/10/18
to MIT App Inventor Forum
The calendar math for this was fun, so
I put up with the 42 button tedium to make a sample.

See attached
ABG

Capture.PNG
Designer.PNG
June 10th.PNG
blocks.png
button_calendar.aia
Reply all
Reply to author
Forward
0 new messages