如何用for循环显示每个问题?

时间:2017-01-24 12:46:00

标签: loops for-loop button

当我点击是或否按钮时,我想看下一个问题。 第一个问题已在main_activity.xml上准备好了,但要查看第二个问题,用户应该回答是或否按钮。我怎么能这样做?

    final TextView questionsText;
    Button buttonYes;
    Button buttonNo;

    String questions[] = new String[7];
    questions[0] = "Second question about depression";
    questions[1] = "Third question about depression";
    questions[2] = "Fourth question about depression";

    questionsText = (TextView) findViewById(R.id.text1);
    buttonYes = (Button) findViewById(R.id.buttonYes);
    buttonNo = (Button) findViewById(R.id.buttonNo);

    buttonYes.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < 7; i++) {
                questionsText.setText(i);
            }
        }
    });

    buttonNo.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            for (int i = 0; i < 7; i++) {
                questionsText.setText(i);
            }
        }
    });
} }

0 个答案:

没有答案