对不起,noob android dev在这里,我试图理解为什么eclipse希望我的TextView被声明为final。
TheStack theStack = new TheStack(10);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView display = (TextView) findViewById(R.id.tv1);
Button b0 = (Button) findViewById(R.id.b0);
b0.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
theStack.push("0");
display.setText(theStack.getStack());
}
});
}
答案 0 :(得分:1)
简短回答:因为你在内部类中使用display
。
答案很长:Why are only final variables accessible in anonymous class?