java - Access variable from inner class without making it final -
how work:
public void onstart() { super.onstart(); int dayn = 0; int = 0; string day = null; string addfach; string mo1 = null; string mo2 = null; string mo3 = null; string mo4 = null; string mo5 = null; string mo6 = null; string mo7 = null; string mo8 = null; string mo9 = null; string mo10 = null; string mo11 = null; string di1 = null; string di2 = null; string di3 = null; string di4 = null; string di5 = null; string di6 = null; string di7 = null; string di8 = null; string di9 = null; string di10 = null; string di11 = null; string mi1 = null; string mi2 = null; string mi3 = null; string mi4 = null; string mi5 = null; string mi6 = null; string mi7 = null; string mi8 = null; string mi9 = null; string mi10 = null; string mi11 = null; string do1 = null; string do2 = null; string do3 = null; string do4 = null; string do5 = null; string do6 = null; string do7 = null; string do8 = null; string do9 = null; string do10 = null; string do11 = null; string fr1 = null; string fr2 = null; string fr3 = null; string fr4 = null; string fr5 = null; string fr6 = null; string fr7 = null; string fr8 = null; string fr9 = null; string fr10 = null; string fr11 = null; while (dayn <= 4) { if (dayn == 0) { day = "montag"; } else if (dayn == 1) { day = "dienstag"; } else if (dayn == 2) { day = "mittwoch"; } else if (dayn == 3) { day = "donnerstag"; } else if (dayn == 4) { day = "freitag"; } while (i <= 10) { bufferedreader buf; try { buf = new bufferedreader(new filereader("/sdcard/" + + day + "fach.txt")); addfach = buf.readline(); if (day == "montag") { if (i == 0) mo1 = addfach; else if (i == 1) mo2 = addfach; else if (i == 2) mo3 = addfach; else if (i == 3) mo4 = addfach; else if (i == 4) mo5 = addfach; else if (i == 5) mo6 = addfach; else if (i == 6) mo7 = addfach; else if (i == 7) mo8 = addfach; else if (i == 8) mo9 = addfach; else if (i == 9) mo10 = addfach; else if (i == 10) mo11 = addfach; } else if (day == "dienstag") { if (i == 0) di1 = addfach; else if (i == 1) di2 = addfach; else if (i == 2) di3 = addfach; else if (i == 3) di4 = addfach; else if (i == 4) di5 = addfach; else if (i == 5) di6 = addfach; else if (i == 6) di7 = addfach; else if (i == 7) di8 = addfach; else if (i == 8) di9 = addfach; else if (i == 9) di10 = addfach; else if (i == 10) di11 = addfach; } else if (day == "mittwoch") { if (i == 0) mi1 = addfach; else if (i == 1) mi2 = addfach; else if (i == 2) mi3 = addfach; else if (i == 3) mi4 = addfach; else if (i == 4) mi5 = addfach; else if (i == 5) mi6 = addfach; else if (i == 6) mi7 = addfach; else if (i == 7) mi8 = addfach; else if (i == 8) mi9 = addfach; else if (i == 9) mi10 = addfach; else if (i == 10) mi11 = addfach; } else if (day == "donnerstag") { if (i == 0) do1 = addfach; else if (i == 1) do2 = addfach; else if (i == 2) do3 = addfach; else if (i == 3) do4 = addfach; else if (i == 4) do5 = addfach; else if (i == 5) do6 = addfach; else if (i == 6) do7 = addfach; else if (i == 7) do8 = addfach; else if (i == 8) do9 = addfach; else if (i == 9) do10 = addfach; else if (i == 10) do11 = addfach; } else if (day == "freitag") { if (i == 0) fr1 = addfach; else if (i == 1) fr2 = addfach; else if (i == 2) fr3 = addfach; else if (i == 3) fr4 = addfach; else if (i == 4) fr5 = addfach; else if (i == 5) fr6 = addfach; else if (i == 6) fr7 = addfach; else if (i == 7) fr8 = addfach; else if (i == 8) fr9 = addfach; else if (i == 9) fr10 = addfach; else if (i == 10) fr11 = addfach; } } catch (exception e) { } i++; } = 0; dayn++; } radiobutton rb1 = (radiobutton) getview().findviewbyid(r.id.stunde1); radiobutton rb2 = (radiobutton) getview().findviewbyid(r.id.stunde2); radiobutton rb3 = (radiobutton) getview().findviewbyid(r.id.stunde3); radiobutton rb4 = (radiobutton) getview().findviewbyid(r.id.stunde4); radiobutton rb5 = (radiobutton) getview().findviewbyid(r.id.stunde5); radiobutton rb6 = (radiobutton) getview().findviewbyid(r.id.stunde6); radiobutton rb7 = (radiobutton) getview().findviewbyid(r.id.stunde7); radiobutton rb8 = (radiobutton) getview().findviewbyid(r.id.stunde8); radiobutton rb9 = (radiobutton) getview().findviewbyid(r.id.stunde9); radiobutton rb10 = (radiobutton) getview().findviewbyid(r.id.stunde10); radiobutton rb11 = (radiobutton) getview().findviewbyid(r.id.stunde11); datepicker dp = (datepicker) getview().findviewbyid(r.id.datepicker); dp.init(dp.getyear(), dp.getmonth(), dp.getdayofmonth(), new datepicker.ondatechangedlistener() { public void ondatechanged(datepicker view, int year, int monthofyear, int dayofmonth) { calendar cal = calendar.getinstance(); cal.set(year, monthofyear, dayofmonth); int dayofweek = cal.get(calendar.day_of_week); switch(dayofweek) { case calendar.monday: rb1.settext(mo1); break; } } }); }
it should set text of radiobuttons depending on weekday of chosen date datepicker. cant set strings final because assigned value 2 times.
if declare them member variables (outside of method , preferably before oncreate()
readibility) accessible throughout activity
inner classes of activity
Comments
Post a Comment