Some test text!

menu
List containerkeyboard_arrow_down

Display & customize list container in Android

The list container provides a horizontal layout to display the following items in separate tabs:

Bookmarks dialog

linkShow list container

The list container is implemented by the BookmarksDialogFragment class. To show this fragment in your activity, create a new instance of BookmarksDialogFragment by calling newInstance(). Afterwards, initialize your fragment by setting the PDFViewCtrl and an ArrayList of DialogFragmentTab:

private PDFViewCtrl mPdfViewCtrl;
// ...
public void showBookmarksDialog(ArrayList<DialogFragmentTab> dialogFragmentTabs,
                                FragmentManager fragmentManager) {
    BookmarksDialogFragment fragment = BookmarksDialogFragment.newInstance();
    fragment.setPdfViewCtrl(mPdfViewCtrl)
            .setDialogFragmentTabs(dialogFragmentTabs);
    // Set a custom style for this fragment
    fragment.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);
    // Show the dialog
    fragment.show(fragmentManager, "bookmarks_dialog");
}

DialogFragmentTab specifies the information about each tab including the type of class and the tab tag. You can create an instance of DialogFragmentTab using DialogFragmentTab(Class<?>, String). Currently the following dialogs can be displayed within the bookmarks dialog:

DialogType of classTab tag
Annotation listAnnotationDialogFragment.classTAG_TAB_ANNOTATION
Document outlineOutlineDialogFragment.classTAG_TAB_OUTLINE
User bookmark listUserBookmarkDialogFragment.classTAG_TAB_BOOKMARK

The following example shows how to display an annotations list, a document outline, and a user-defined bookmark list tabs in BookmarksDialogFragment:

BookmarksDialogFragment showBookmarksDialog(FragmentManager fragmentManager, PDFViewCtrl pdfViewCtrl) {
    DialogFragmentTab annotationsDialog = new DialogFragmentTab(
        AnnotationDialogFragment.class,
        BookmarksTabLayout.TAG_TAB_ANNOTATION,
        null,
        "Annotations",
        "Bookmarks Dialog",
        null);
    DialogFragmentTab outlineDialog = new DialogFragmentTab(
        UserBookmarkDialogFragment.class,
        BookmarksTabLayout.TAG_TAB_OUTLINE,
        null,
        "Outline",
        "Bookmarks Dialog",
        null);
    DialogFragmentTab userBookmarksDialog = new DialogFragmentTab(
        UserBookmarkDialogFragment.class,
        BookmarksTabLayout.TAG_TAB_BOOKMARK,
        null,
        "User Bookmarks",
        "Bookmarks Dialog",
        null);
    ArrayList<DialogFragmentTab> dialogFragmentTabs = new ArrayList<>();
    dialogFragmentTabs.add(annotationsDialog);
    dialogFragmentTabs.add(outlineDialog);
    dialogFragmentTabs.add(userBookmarksDialog);
    BookmarksDialogFragment bookmarksDialog = BookmarksDialogFragment.newInstance();
    bookmarksDialog.setPdfViewCtrl(pdfViewCtrl)
        .setDialogFragmentTabs(dialogFragmentTabs);
    bookmarksDialog.setBookmarksDialogListener(this)
    bookmarksDialog.setBookmarksTabsListener(this);
    bookmarksDialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);   
    bookmarksDialog.show(fragmentManager, "bookmarks_dialog");
    return bookmarksDialog;
}

@Override
public void onBookmarksDialogDismissed(int tabIndex) {
    // the bookmarks dialog was dismissed
}

@Override
public void onUserBookmarkClick(int pageNum) {
    // a user bookmark was clicked
}

@Override
public void onOutlineClicked(Bookmark parent, Bookmark bookmark) {
    // an outline was clicked
}

@Override
public void onAnnotationClicked(Annot annotation, int pageNum) {
    // an annotation was clicked
}

@Override
public void onExportAnnotationsClicked() {
    // the export annotation button was clicked
}

linkCustomization

The BookmarksDialogFragment provides a flexible API for displaying only the desired child view. Any of the annotation list, document outline, or user-defined bookmark list view can be removed by omitting them from the DialogFragmentTabs.

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

Join our upcoming webinar to learn about how to collaborate on videos frame by frame directly in your browser

Save your seat
close