public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText stringtext; // final error here
stringtext = (EditText) findViewById(R.id.editText);
TextView textView2; // final error here
textView2 = (TextView) findViewById(R.id.textView2);
Button startprogram = (Button) findViewById(R.id.button);
View.OnClickListener listener = new View.OnClickListener(){
@Override
public void onClick(View view){
// Insert what you want the button to do here!
setContentView(R.layout.helloworld);
}
};
startprogram.setOnClickListener(listener);
// this is button to check the inserted code
Button checkbutton = (Button) findViewById(R.id.checkbutton);
View.OnClickListener listener1 = new View.OnClickListener(){
public void onClick(View view){
//insert button command here
textView2.setText(stringtext.getEditableText());
}
};
}
我收到一条错误消息,指出局部变量 stringtext 和 textview2 需要最终确定?如果我最终完成它们,那么如果我正确的话它们就不会更新......?
最佳答案
final
只是意味着变量的引用不能更改。对象状态仍然会正确更改。
关于java - 我收到一条错误消息,指出局部变量 stringtext 和 textview2 需要最终确定?如果我最终完成它们,那么如果我正确的话它们就不会更新......?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31929298/