Why not
AlertDialogBuilder builder = new AlertDialogBuilder(this);
builder.setTitle("foo");
instead of
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("foo");
Update: I want to know the reason behind this kind of writing/organization
Builder is the static inner class inside the AlertDialog class. So to create a Builder class object, you need to call AlertDialog.Builder.
As there is no class like AlertDialogBuilder so you cannot do that.
If you want you can also use as like bellow.
But to use like this you need to import the Builder class to your class like
instead of just
A simple example
you cannot use
you have to use
Hope you are clear now.