简体   繁体   中英

Week View of calendar in android

I am developing an Android application. Now on the click of the Spinner the calendar will open.Now that calendar should be in week view and on click of the specific date I have to call one Activity as per my requirement.Anybody guide me for this.

Thanks for your time.

Try this,

Calendar c;
int date;
int month;
int year;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.change_booking_date);
    c = Calendar.getInstance();
    dates = new String[7];
    date = c.get(Calendar.DAY_OF_MONTH);
    month = c.get(Calendar.MONTH)+1;
    year = c.get(Calendar.YEAR);
}

Increment the dates and update them accordingly.

public void updateDate() {
    if (date > c.getMaximum(Calendar.DAY_OF_MONTH)) {
        date = 1;
        month++;
        updateMonth();
    }
    else 
        date++;
}
public void updateMonth() {
    if (month > c.getMaximum(Calendar.MONTH)) {
        month = 1;
        year++;
    }
    else
        month++;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM