public class GuizActivity extends AppCompatActivity {
private Button mTrueButton;
private Button mFalseButton;
private Button mNextButton;
private TextView mTV;
private int mCurrentIndex = 0;
TrueFalse[] mQuesitonBank = new TrueFalse[]{
new TrueFalse(R.string.onn, true),
new TrueFalse(R.string.inn, true),
new TrueFalse(R.string.gcc, true),
};
@Override
protected void onCreate extends GuizActivitiy (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_guiz);
mTV = (TextView) findViewById(R.id.TV);
final int question = mQuesitonBank[mCurrentIndex].getQuestion();
mTV.setText(question);
mTrueButton = (Button) findViewById(R.id.button_true);
mFalseButton = (Button) findViewById(R.id.button_false);
mNextButton = (Button) findViewById(R.id.button_next);
mNextButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
mCurrentIndex = (mCurrentIndex++) % mQuesitonBank.length;
int guestion = mQuesitonBank[mCurrentIndex].getQuestion();
mTV.setText(question);
}
});
}
mTrueButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
Toast.makeText(GuizActivity.this, R.string.correct_toast, Toast.LENGTH_SHORT).show();
}
});
mFalseButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View view){
Toast.makeText( GuizActivity.this, R.string.incorrect_toast, Toast.LENGTH_SHORT).show();
}
});
}
protected boolean onCreateOptionMeny(Menu menu){
return true;
}
}
P.S. Я знаю, что так делать нельзя (protected void onCreate extends GuizActivitiy (Bundle savedInstanceState) {
) , но я хотел бы знать почему так делать нельзя!!
P.P.S. в методе
mNextButton.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
mCurrentIndex = (mCurrentIndex++) % mQuesitonBank.length;
int guestion = mQuesitonBank[mCurrentIndex].getQuestion();
mTV.setText(question);
}
});
мы создаем две новые переменные или переопределяем их?