protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = DataBindingUtil.setContentView(MainActivity.this,R.layout.activity_main); setContentView(binding.getRoot()); binding.textView.setTextSize(18); for (int i = 0; i < questionBank.length;) { Questions questions = questionBank[i]; binding.textView.setText(questions.getAnswerResId()); binding.button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (questions.isAnswerTrue()) { Toast.makeText(MainActivity.this, R.string.correct_answer, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(MainActivity.this, R.string.wrong_answer, Toast.LENGTH_SHORT).show(); } } });
binding.button2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!questions.isAnswerTrue()) {
Toast.makeText(MainActivity.this, R.string.correct_answer, Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(MainActivity.this, R.string.wrong_answer, Toast.LENGTH_SHORT).show();
}
}
});
}
}