Muhammad Firdaus Fadli:
Por lo que estoy haciendo un código que el valor int usos en una cadena (codificado por cierto), que funciona, pero cuando incrementa el valor de la int por clic de botón, el int en la cadena no cambia como el incremento.
int indexOfQuestion= 1;
numberOfQuestion.setText("Question " + indexOfQuestion + " from " + lengthOfQuestion + " :" );
switch(v.getId()):
case R.id.next:
indexOfQuestion = indexOfQuestion+1;
así que cuando hace clic en el botón, indexOfQuestion en estancias numberOfQuestion 1. ¿Cómo se cambia automáticamente como era mi intención, sin tiempo detallado códigos? Gracias
Matin gdz:
no va a cambiar porque setText antes incremento del valor int. si desea aplicar los cambios, debe setText nuevo después de la incrementación.
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 + " :" );