我在Android Studio上遇到错误。我的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);
}
}
请帮我解决这个问题。我无法完成应用程序。谢谢
答案 0 :(得分:2)
您在方法参数中将paramView声明为final。你无法修改最终变量(这就是为什么它被称为最终变量,实际上)。
答案 1 :(得分:0)
将变量声明为final后,您无法更改它。