public ChooserDialog build() {
        TypedArray ta = _context.obtainStyledAttributes(R.styleable.FileChooser);
        final AlertDialog.Builder builder = new AlertDialog.Builder(_context,
            ta.getResourceId(R.styleable.FileChooser_fileChooserDialogStyle, R.style.FileChooserDialogStyle));
        final int style = ta.getResourceId(R.styleable.FileChooser_fileChooserListItemStyle,
            R.style.FileChooserListItemStyle);
        ta.recycle();
        final Context context = new ContextThemeWrapper(_context, style);
        ta = context.obtainStyledAttributes(R.styleable.FileChooser);
        final int listview_item_selector = ta.getResourceId(R.styleable.FileChooser_fileListItemFocusedDrawable,
            R.drawable.listview_item_selector);
        ta.recycle();

        _adapter = new DirAdapter(context, this._dateFormat);
        if (_adapterSetter != null) _adapterSetter.apply(_adapter);

        refreshDirs();
        builder.setAdapter(_adapter, this);

        if (!_disableTitle) {
            if (_titleRes != -1) {
                builder.setTitle(_titleRes);
            } else if (_title != null) {
                builder.setTitle(_title);
            } else {
                builder.setTitle(R.string.choose_file);
            }
        }

        if (_iconRes != -1) {
            builder.setIcon(_iconRes);
        } else if (_icon != null) {
            builder.setIcon(_icon);
        }

        if (_layoutRes != -1) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                builder.setView(_layoutRes);
            }
        }

        if (_dirOnly || _enableMultiple) {
            // choosing folder, or multiple files picker
            DialogInterface.OnClickListener listener = (dialog, which) -> {
                if (_result != null) {
                    _result.onChoosePath(_currentDir.getAbsolutePath(), _currentDir);
                }
            };
            if (_okRes != -1) {
                builder.setPositiveButton(_okRes, listener);
            } else if (_ok != null) {
                builder.setPositiveButton(_ok, listener);
            } else {
                builder.setPositiveButton(R.string.title_choose, listener);
            }
        }

        if (_negativeRes != -1) {
            builder.setNegativeButton(_negativeRes, _negativeListener);
        } else if (_negative != null) {
            builder.setNegativeButton(_negative, _negativeListener);
        } else {
            builder.setNegativeButton(R.string.dialog_cancel, _negativeListener);
        }

        if (_cancelListener != null) {
            builder.setOnCancelListener(_cancelListener);
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && _onDismissListener != null) {
            builder.setOnDismissListener(_onDismissListener);
        }

        builder.setOnKeyListener(new keyListener(this));

        _alertDialog = builder.create();

        _alertDialog.setCanceledOnTouchOutside(this._cancelOnTouchOutside);
        _alertDialog.setOnShowListener(new onShowListener(this));

        _list = _alertDialog.getListView();
        _list.setOnItemClickListener(this);
        if (_enableMultiple) {
            _list.setOnItemLongClickListener(this);
        }

        if (_enableDpad) {
            _list.setSelector(listview_item_selector);
            _list.setDrawSelectorOnTop(true);
            _list.setItemsCanFocus(true);
            _list.setOnItemSelectedListener(this);
            _list.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        }

        _list.requestFocus();
        return this;
    }
allows dialog title follows the current folder name

@param followDir dialog title will follow the changing of directory
@return this
android-file-chooser/src/main/java/com/obsez/android/lib/filechooser/ChooserDialog.java