My problem is this:
I have a string Array with the name phrases, where I have several phrases.
And I would like to show them all in the same%% of each by pressing the "next" button.
Any tip will be well received thank you.
My problem is this:
I have a string Array with the name phrases, where I have several phrases.
And I would like to show them all in the same%% of each by pressing the "next" button.
Any tip will be well received thank you.
Hello!
Here's an example of how your OnCLick
should be:
int ponteiro = 0;
private View.OnClickListener nextAction(){
return new View.OnClickListener() {
@Override
public void onClick(View v) {
// vamos ver se o ponteiro é menor que o tamanho da lista
// tiramos 1, pois abaixo vamos adicionar mais 1!
if(ponteiro < (frases.size()-1) ){
// vamos andar uma posição com o ponteiro
ponteiro++;
}else{
// vamos zerar o ponteiro
ponteiro = 0;
}
// Agora vamos mostrar o item da Lista
meuTextView.setText(frases.get(ponteiro));
};
}
To add the action on your button:
botaoProximo.setOnClickListener(nextAction());