The dialog builder
As well as being essential to all but a few apps, Android dialogs offer a great way to see how the framework itself employs design patterns. In this case, it is the dialog builder, which strings together a series of setters to build our dialog.
In the current situation, all we really need is a very simple dialog allowing the user to confirm their selection, but dialog construction is a very interesting topic and so we will take a closer look at how it is done and how inbuilt builder patterns are used to construct them.
The dialog we are about to build will, if confirmed, take the user to another activity, so before we do that we should create that activity. This is easily done by selecting New | Activity | Blank Activity
from the project explorer menu. Here we have called it CheckoutActivity.java
.
Once you have created this activity, follow these two steps:
The floating action button onClickListener will build and inflate our dialog. It is quite lengthy, so create a new method...