0

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.

Vivek Kalkur
  • 2,200
  • 2
  • 21
  • 40
Kushal Shah
  • 1,303
  • 2
  • 17
  • 33

1 Answers1

1

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++;
}
Hiral Vadodaria
  • 19,158
  • 5
  • 39
  • 56
Noby
  • 6,562
  • 9
  • 40
  • 63
  • Thanx for your suggestion. but how would i get that View which i am looking for? Like in phone there is calendar with month view like that i want week view. – Kushal Shah Nov 18 '11 at 11:48
  • you need to design custom view for that. – Noby Nov 18 '11 at 11:50
  • use 7 buttons horizontally representing days. – Noby Nov 18 '11 at 11:51
  • ok thank you and i there any way to view the events in the phone's calendar from my app? or is it possible to do so? – Kushal Shah Nov 18 '11 at 11:57
  • ya you can do that. follow this link for more info. http://stackoverflow.com/questions/4302209/android-calendar-events – Noby Nov 18 '11 at 12:17