[Solved] Button to show previous string


create a new member for your Activity like:

int actual = 0;

Then create a ‘next’ button:

nextButton = (Button) findViewById(...);

nextButton.setOnClickListener(new OnClickListener()
{
    @Override
    public void onClick(View arg0)
    {
        actual = actual < countires.length - 1 ? actual + 1 : actual;
        String  country  = countires[actual];
        btn1.setText(country);
    }
});

Same goes for the previous button:

prevButton = (Button) findViewById(...);

prevButton.setOnClickListener(new OnClickListener()
{
    @Override
    public void onClick(View arg0)
    {
        actual = actual > 0 ? actual - 1 : actual;
        String  country  = countires[actual];
        btn1.setText(country);
    }
});

1

solved Button to show previous string