Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
384 views
in Technique[技术] by (71.8m points)

java - Getting the dates of the current week in Android

I have these 5 buttons in my program: Monday, Tuesday, Wednesday, Thursday and Friday, which are on my menu screen. What I want now is that when my program starts and my menu screen opens, the buttons contain the days + the dates of the day.

For example, today we're the fourth of may (happy Star Wars day!) and the buttons should be like this:

Monday 04/30 Tuesday 05/01 Wednesday 05/02 Thursday 05/03 Friday 05/04

But when I open the menu screen next monday it should be like this: Monday 05/07 Tuesday 05/08 Wednesday 05/09 Thursday 05/10 Friday 05/11

How can I do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess the following two threads is all you will need to get you started. And as Ian mentioned do go through the android Calendar and Date api's. Although I should mention most of the methods of Date api is deprecated. Calendar is generally preferred.

Android Get Current Time and Date

Display Current Time And Date in Android application


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...