Android 无法将值赋给最终变量';paramView&x27;

Android 无法将值赋给最终变量';paramView&x27;,android,settext,Android,Settext,我在安卓工作室有个错误。我的paramView是红色的,我不知道为什么这里是我的代码:错误在大标记代码处 public void plusOne(final View paramView) { Object localObject; if (this.scoreInteger == 0) { localObject = new Timer(); this.timerTask = new

我在安卓工作室有个错误。我的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);
        }
    }
public void plusOne(最终视图)
{
对象本地对象;
if(this.scoreInteger==0)
{
localObject=new Timer();
this.timerTask=new timerTask()
{
公开募捐
{
paramView.post(新的Runnable()
{
公开募捐
{
((TextView)MainActivity.this.findviewbyd(R.id.timer)).setText(MainActivity.this.myTimer+);
MainActivity localMyActivity=MainActivity.this;
localMyActivity.myTimer+=1;
}
});
}
};
((Timer)localObject).schedule(this.timerTask,0L,10L);
}
这是一个整数+=1;
if(this.scoreInteger<10)
{
((按钮)findviewbyd(R.id.highScore)).setText(String.valueOf(this.scoreInteger));
返回;
}
this.timerTask.cancel();
this.timerTask=null;
**paramView=(按钮)findViewById(R.id.plusOne);
setText(String.valueOf(this.scoreInteger))**
paramView.setVisibility(视图.不可见);
((按钮)findviewbyd(R.id.reset)).setVisibility(View.VISIBLE);
((ImageView)findViewById(R.id.ImageView)).setVisibility(View.VISIBLE);
**paramView=(TextView)findViewById(R.id.timer)**
if(this.myTimer

请帮我解决那个问题。我无法完成应用程序。谢谢

您在方法参数中将paramView声明为final。您不能修改最终变量(这就是为什么它被称为最终变量)。

一旦您将变量声明为最终变量,您就不能更改它。

如果它声明为最终变量,那么它是一个常量,而不是一个变量。这意味着一旦设定,你就不能改变它。为什么?你为什么不喜欢?我不明白!