我想知道如何将事物从一个虚空“共享”到另一个虚空。我有两个空白:一个称为“Setup”,一个称为“NextQuestionAnswer”。我在“设置”中有一个变量,我需要从“NextQuestionAnswer”空白处访问它。我见过其他类似的问题,但似乎没有任何帮助。这是我想要实现的代码。
我的问题是我不能将 TextView 声明为全局变量,因为它不接受公共或静态。
public void setup() {
ArrayList<String> questions = new ArrayList<String>();
ArrayList<String> answers = new ArrayList<String>();
ArrayList<String> correctanswers = new ArrayList<String>();
TextView question = (TextView)(findViewById(R.id.textboxquestion));
RadioButton ac1 = (RadioButton)(findViewById(R.id.radiobuttona));
RadioButton ac2 = (RadioButton)(findViewById(R.id.radiobuttonb));
RadioButton ac3 = (RadioButton)(findViewById(R.id.radiobuttonc));
RadioButton ac4 = (RadioButton)(findViewById(R.id.radiobuttond));
}
public void NextQuestionAnswer() {
question.setText("something here"); ---THIS IS THE LINE THAT I WANT TO BE ABLE TO DO
}