안드로이드 앱에서 사용자가 임의의 합계에 답변 할 수있게하려는 경우 새 앱이 화면에 표시됩니다. 이것은 10 번 반복되고 마지막 점수가 주어진다. 그러나 나는 각각의 새로운 랜덤이 화면에 보여 지도록 합계를 업데이트하는 방법을 확신하지 못합니다. 다음은 Android : 각 클릭 후 새로운 임의의 합계?
내 현재 코드입니다 : 사용자 언론이 질문을 업데이트 버튼을 깨끗하고 이전의 모든 값을 제출할 때 있도록public class Test extends Activity {
//declare vars
TextView text;
EditText answer;
Button submit;
int random1;
int random2;
String question;
int correctAnswer;@
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
// initialising variables
initialiseVars();
//set up random
setUpRandom();
//Set text view equal to question
text.setText(question);
//updateQuestion?
}
public void initialiseVars() {
text = (TextView) findViewById(R.id.tvTopRandomTest);
answer = (EditText) findViewById(R.id.etEnterAnswerRandomTest);
submit = (Button) findViewById(R.id.btnSubmitRandomTest);
}
public void setUpRandom() {
//setting up randoms
Random random = new Random();
// Generating random number between 1 and 12
random1 = random.nextInt(12) + 1;
// Generating another random number between 1 and 12
random2 = random.nextInt(12) + 1;
question = random1 + " x " + random2 + " = ";
correctAnswer = random1 * random2;
}
public void updateQuestion() {
//CODE TO UPDATE QUESTION
}
}
무엇이 문제입니까? –
사용자가 '제출'을 클릭 할 때마다 번호를 변경 하시겠습니까? –
사용자가 합계에 대한 답변을 입력 할 때마다 텍스트 뷰를 응답 할 수 있도록 다른 임의의 합계로 새로 고치기를 원합니다. –