Danny S
Danny S

Reputation: 85

Button misfunction

When user click Next button, it suppose to show next record store in database, but when I run the app, user have to click previous button to view next entry and the Next button didn't perform any activity.

public void onClick(View v) {

        int buttonId = v.getId();

        if (buttonId == R.id.buttonViewPrevious)
            if (currentBoothArrayIndex < boothArrayList.size() - 1) {
                displayBoothInformation(--currentBoothArrayIndex);
            } else if (buttonId == R.id.buttonViewNext)
                if (currentBoothArrayIndex < boothArrayList.size() - 1) {
                    displayBoothInformation(++currentBoothArrayIndex);
                } 
    }

Upvotes: 1

Views: 44

Answers (1)

nano_nano
nano_nano

Reputation: 12523

your if else construct is wrong. Try this:

if (buttonId == R.id.buttonViewPrevious){
   if (currentBoothArrayIndex < boothArrayList.size() - 1) {
     displayBoothInformation(--currentBoothArrayIndex);
   } 
}else if (buttonId == R.id.buttonViewNext){
   if (currentBoothArrayIndex < boothArrayList.size() - 1) {
     displayBoothInformation(++currentBoothArrayIndex);
   } 
}

Upvotes: 3

Related Questions