0
我在Android Studio中出現錯誤。我的paramView是紅色的,我不知道爲什麼這裏是我的代碼:錯誤是在大標記的代碼。無法將值分配給最終變量'paramView'
public void plusOne(final View paramView)
{
Object localObject;
if (this.scoreInteger == 0)
{
localObject = new Timer();
this.timerTask = new TimerTask()
{
public void run()
{
paramView.post(new Runnable()
{
public void run()
{
((TextView)MainActivity.this.findViewById(R.id.timer)).setText(MainActivity.this.myTimer + "");
MainActivity localMyActivity = MainActivity.this;
localMyActivity.myTimer += 1;
}
});
}
};
((Timer)localObject).schedule(this.timerTask, 0L, 10L);
}
this.scoreInteger += 1;
if (this.scoreInteger < 10)
{
((Button)findViewById(R.id.highScore)).setText(String.valueOf(this.scoreInteger));
return;
}
this.timerTask.cancel();
this.timerTask = null;
**paramView = (Button)findViewById(R.id.plusOne);
paramView.setText(String.valueOf(this.scoreInteger));**
paramView.setVisibility(View.INVISIBLE);
((Button)findViewById(R.id.reset)).setVisibility(View.VISIBLE);
((ImageView)findViewById(R.id.imageView)).setVisibility(View.VISIBLE);
**paramView = (TextView)findViewById(R.id.timer);**
if (this.myTimer < this.myHighScore)
{
this.myHighScore = this.myTimer;
localObject = getSharedPreferences("your_prefs", 0).edit();
((SharedPreferences.Editor)localObject).putInt("your_int_key", this.myHighScore);
((SharedPreferences.Editor)localObject).commit();
}
for (;;)
{
paramView.**setText**(this.highScoreString + String.valueOf(this.myHighScore));
paramView.setVisibility(View.VISIBLE);
return;
this.myHighScore = getSharedPreferences("your_prefs", 0).getInt("your_int_key", 0);
}
}
請幫我解決這個問題。我無法完成應用程序。謝謝你
如果它被聲明爲** final **,那麼它是**常量**,而不是**變量**。這意味着一旦設置就無法更改它。 –
爲什麼?你爲什麼不喜歡?我不明白! – logtainment