Challenge: Add a Listener to the TextView


#1

Hi,

This is my solution for the first Challenge:

    mQuestionTextView = (TextView)findViewById(R.id.question_text_view);

    mQuestionTextView.setOnClickListener(new View.OnClickListener(){
        @Override

        public void onClick(View v){

            mCurrentIndex=(mCurrentIndex+1)% mQuestionBank.length;
            updateQuestion();

        }

    });

#2

Hi!

The same code is used twice: 1) in button ‘Next’, 2) in TextView listener
So I prefer to move it into separate method

private void moveNext() {
    currentIndex = (currentIndex + 1) % questionBank.length;
    updateQuestion();
}

#3

With regards to this line:

`mCurrentIndex=(mCurrentIndex+1)% mQuestionBank.length;`

Why is it necessary to include % mQuestionBank.length;?