Why not
AlertDialogBuilder builder = new AlertDialogBuilder(this);
builder.setTitle(\"foo\");
instead of
AlertDialog.Builder
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.
Builder builder = new Builder(this);
builder.setTitle("foo");
But to use like this you need to import the Builder class to your class like
import android.app.AlertDialog.Builder;
instead of just
import android.app.AlertDialog;
A simple example
class A{
static class B{}
}
you cannot use
AB obj = new AB();
you have to use
A.B obj = new A.B();
Hope you are clear now.