Display & customize list container in Android

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

Apryse Docs Image

Show 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:

1private PDFViewCtrl mPdfViewCtrl;
2// ...
3public void showBookmarksDialog(ArrayList<DialogFragmentTab> dialogFragmentTabs,
4 FragmentManager fragmentManager) {
5 BookmarksDialogFragment fragment = BookmarksDialogFragment.newInstance();
6 fragment.setPdfViewCtrl(mPdfViewCtrl)
7 .setDialogFragmentTabs(dialogFragmentTabs);
8 // Set a custom style for this fragment
9 fragment.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);
10 // Show the dialog
11 fragment.show(fragmentManager, "bookmarks_dialog");
12}

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:

Dialog

Type of class

Tab tag

Annotation list

AnnotationDialogFragment.class

TAG_TAB_ANNOTATION

Document outline

OutlineDialogFragment.class

TAG_TAB_OUTLINE

User bookmark list

UserBookmarkDialogFragment.class

TAG_TAB_BOOKMARK

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

1BookmarksDialogFragment showBookmarksDialog(FragmentManager fragmentManager, PDFViewCtrl pdfViewCtrl) {
2 DialogFragmentTab annotationsDialog = new DialogFragmentTab(
3 AnnotationDialogFragment.class,
4 BookmarksTabLayout.TAG_TAB_ANNOTATION,
5 null,
6 "Annotations",
7 "Bookmarks Dialog",
8 null);
9 DialogFragmentTab outlineDialog = new DialogFragmentTab(
10 UserBookmarkDialogFragment.class,
11 BookmarksTabLayout.TAG_TAB_OUTLINE,
12 null,
13 "Outline",
14 "Bookmarks Dialog",
15 null);
16 DialogFragmentTab userBookmarksDialog = new DialogFragmentTab(
17 UserBookmarkDialogFragment.class,
18 BookmarksTabLayout.TAG_TAB_BOOKMARK,
19 null,
20 "User Bookmarks",
21 "Bookmarks Dialog",
22 null);
23 ArrayList<DialogFragmentTab> dialogFragmentTabs = new ArrayList<>();
24 dialogFragmentTabs.add(annotationsDialog);
25 dialogFragmentTabs.add(outlineDialog);
26 dialogFragmentTabs.add(userBookmarksDialog);
27 BookmarksDialogFragment bookmarksDialog = BookmarksDialogFragment.newInstance();
28 bookmarksDialog.setPdfViewCtrl(pdfViewCtrl)
29 .setDialogFragmentTabs(dialogFragmentTabs);
30 bookmarksDialog.setBookmarksDialogListener(this)
31 bookmarksDialog.setBookmarksTabsListener(this);
32 bookmarksDialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);
33 bookmarksDialog.show(fragmentManager, "bookmarks_dialog");
34 return bookmarksDialog;
35}
36
37@Override
38public void onBookmarksDialogDismissed(int tabIndex) {
39 // the bookmarks dialog was dismissed
40}
41
42@Override
43public void onUserBookmarkClick(int pageNum) {
44 // a user bookmark was clicked
45}
46
47@Override
48public void onOutlineClicked(Bookmark parent, Bookmark bookmark) {
49 // an outline was clicked
50}
51
52@Override
53public void onAnnotationClicked(Annot annotation, int pageNum) {
54 // an annotation was clicked
55}
56
57@Override
58public void onExportAnnotationsClicked() {
59 // the export annotation button was clicked
60}

Customization

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.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales