ムハンマドFadliフィルダウス:
私は(ところでハードコード)文字列内のint値を使用するコードを作ってるんだだから、それは動作しますが、私はボタンクリックでint型の値をインクリメントするとき、文字列のintは増分として変更されません。
int indexOfQuestion= 1;
numberOfQuestion.setText("Question " + indexOfQuestion + " from " + lengthOfQuestion + " :" );
switch(v.getId()):
case R.id.next:
indexOfQuestion = indexOfQuestion+1;
私はボタンをクリックしたときに、私は長い冗長なコードなしで意図したように、numberOfQuestion滞在中indexOfQuestion 1.どのように私はそれを自動的に変更するには?感謝
MatinのGdz:
あなたがint値をインクリメントする前に、あなたがのsetTextので、それは変更されません。あなたが変更を適用したい場合は、インクリメントした後、再度のsetText必要があります。
int indexOfQuestion= 1;
numberOfQuestion.setText("Question " + indexOfQuestion + " from " + lengthOfQuestion + " :" );
switch(v.getId()):
case R.id.next: indexOfQuestion = indexOfQuestion+1;
numberOfQuestion.setText("Question " + indexOfQuestion + " from " + lengthOfQuestion + " :" );