我的应用程序有问题,我无法弄清楚问题是什么。在 ICS 上该应用程序可以工作,但在任何 2.X 上它都有问题。我相信它与循环有关,但我仍然有点困惑。
开发人员控制台向我抛出此错误报告:
Exception class > java.lang.StackOverflowError
Source method > Matrix.setScale()
这是导致问题的代码...
private void shiftLoop7()
{
if (d7 != doy && d7 < 366)
{
d7 = d7 + 8;
shiftLoop7();
}
else if(d7 == doy)
{
if (hour >= 0 && hour < 8)
{
shift.setText("C");
shift.setTextAppearance(getApplicationContext(), R.style.CShift);
shiftImage.setImageResource(R.drawable.c);
timeTill.setText("till 7:45 AM");
dayshift.setText("A Shift");
day1.setBackgroundResource(R.color.A);
day2.setBackgroundResource(R.color.A);
day3.setBackgroundResource(R.color.A);
day4.setBackgroundResource(R.color.A);
nightshift.setText("C Shift");
night1.setBackgroundResource(R.color.C);
night2.setBackgroundResource(R.color.C);
night3.setBackgroundResource(R.color.C);
night4.setBackgroundResource(R.color.C);
}
else if (hour >= 8 && hour < 17)
{
shift.setText("A");
shift.setTextAppearance(getApplicationContext(), R.style.AShift);
shiftImage.setImageResource(R.drawable.a);
timeTill.setText("till 4:45 PM");
dayshift.setText("A Shift");
day1.setBackgroundResource(R.color.A);
day2.setBackgroundResource(R.color.A);
day3.setBackgroundResource(R.color.A);
day4.setBackgroundResource(R.color.A);
nightshift.setText("C Shift");
night1.setBackgroundResource(R.color.C);
night2.setBackgroundResource(R.color.C);
night3.setBackgroundResource(R.color.C);
night4.setBackgroundResource(R.color.C);
}
else
{
shift.setText("C");
shift.setTextAppearance(getApplicationContext(), R.style.CShift);
shiftImage.setImageResource(R.drawable.c);
timeTill.setText("till 7:45 AM");
dayshift.setText("A Shift");
day1.setBackgroundResource(R.color.A);
day2.setBackgroundResource(R.color.A);
day3.setBackgroundResource(R.color.A);
day4.setBackgroundResource(R.color.A);
nightshift.setText("C Shift");
night1.setBackgroundResource(R.color.C);
night2.setBackgroundResource(R.color.C);
night3.setBackgroundResource(R.color.C);
night4.setBackgroundResource(R.color.C);
}
}
else
{
shiftLoop8();
}
}