内访问我有这些可变因素:变量是从内部类
private boolean MineRunning;
private BigInteger MineProfit;
etc....
我想调用倒数方法:
countdown(MineRunning, MineProfit, MineTime, MineProgressbar, MineProgressstatus);
约10次为不同的事情
的方法:
private void countdown(boolean running, BigInteger profit, BigInteger time, ProgressBar progressBar, int progressStatus) {
if(!running && Reference.Storage_Filled.add(profit).compareTo(Reference.Storage_Capacity) == 0 ||
!running && Reference.Storage_Filled.add(profit).compareTo(Reference.Storage_Capacity) == -1){
running = true;
new CountDownTimer(time.longValue(), Reference.countDownInterval.longValue()){
public void onTick(long millisUntilFinished){
progressStatus++;
progressBar.setProgress(progressStatus);
}
public void onFinish(){
Reference.totalGravel = Reference.totalGravel.add(profit);
Gravelrefresh();
progressStatus = 0;
progressBar.setProgress(progressStatus);
running = false;
}
}.start();
}
}
如果我把这个方法我得到一个错误:
variable is accessed from within inner class
我不想让可变因素来final
因为我要编辑这些在方法中。我能做些什么呢? 谢谢。
如果我使其最终运行= FALSE;不工作 –
无论如何,这是行不通的 - 你有一个不寻常的函数试图访问和改变一个局部变量。这不可能。这就是规则存在的原因。运行需要是类级别的变量,而不是函数的参数 –