Cannot refer to a non-final variable inside an inner class defined in a different method

前端 未结 20 2266
一向
一向 2020-11-21 05:04

Edited: I need to change the values of several variables as they run several times thorugh a timer. I need to keep updating the values with every iteration through the timer

20条回答
  •  心在旅途
    2020-11-21 05:29

    you can just declare the variable outside the outer class. After this, you will be able to edit the variable from within the inner class. I sometimes face similar problems while coding in android so I declare the variable as global and it works for me.

提交回复
热议问题