Int en la cadena no cambia cuando cambio el valor int

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 + " :" );

Supongo que te gusta

Origin http://43.154.161.224:23101/article/api/json?id=120311&siteId=1
Recomendado
Clasificación