onclick - Can't to use add(Calendar.DAY_OF_MONTH,1) in android -


i tried use button onclick handler add 1 day calendar, throws error, when tap nextday button. that's code fragment:

public class main extends activity { textview dateview;  private int myear; private int mmonth; private int mday; static final int date_dialog_id = 1; gregoriancalendar c;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      dateview = (textview)findviewbyid(r.id.dateview);      gregoriancalendar c = new gregoriancalendar();     myear = c.get(calendar.year);     mmonth = c.get(calendar.month);     mday = c.get(calendar.day_of_month);     } public void nextday(view v) { c.add(calendar.day_of_month, 1); updatedatedisplay(); } private void updatedatedisplay() { string[] month_names = getresources().getstringarray(r.array.month_names);     dateview.settext(         new stringbuilder()                 .append(mday).append(" ")                 .append(month_names[mmonth]).append(" ").append(myear)); } } 

i have tried , doesn't work. this.c.add(calendar.day_of_month, 1);

logcat log:

fatal exception: main java.lang.illegalstateexception: not execute method of activity @ android.view.view$1.onclick(view.java:2072) @ android.view.view.performclick(view.java:2408) @ android.view.view$performclick.run(view.java:8816) @ android.os.handler.handlecallback(handler.java:587) 


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -