I have an error at Android Studio. My paramView is red and i don't know why here is my code: The error is at the big marked code.
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);
}
}
Please help me to solve that Problem. I can't finish the app. Thank You
You declare paramView as final in your method parameters. You can't modify a final variable (that's why it's said to be final, actually).