We now have the buttons for setting the colors working and next, we will add code to allow swapping the selected colors. In MainActivity.java, add the swapColors method:
The method will be called from the click listener for the swap button. Add the listener to the setListeners method:
If you run the app now, you will be able to swap the foreground and background colors. That’s it for this section. You can check the code for MainActivity.java on github.