List Container

The list container is a UI component that contains other components related to annotations and bookmarks.

List container to customize horizontal menu layout in Xamarin.Android

This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here .

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:

C#

1private PDFViewCtrl mPdfViewCtrl;
2// ...
3public void ShowBookmarksDialog(List<DialogFragmentTab> dialogFragmentTabs,
4 FragmentManager fragmentManager) {
5 var fragment = BookmarksDialogFragment.NewInstance();
6 fragment.SetPdfViewCtrl(mPdfViewCtrl)
7 .SetDialogFragmentTabs(dialogFragmentTabs);
8 // Set a custom style for this fragment
9 fragment.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.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. 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:

C#

1using pdftron.PDF.Tools.Utils;
2
3var bookmarksDialog = pdftron.PDF.Dialog.BookmarksDialogFragment.NewInstance();
4bookmarksDialog.SetPdfViewCtrl(mPdfViewCtrl);
5List<DialogFragmentTab> tabs = new List<DialogFragmentTab>();
6var annotationsTab = new DialogFragmentTab(
7 Java.Lang.Class.FromType(typeof(AnnotationDialogFragment)), BookmarksTabLayout.TagTabAnnotation, null, "Annotations", "Bookmarks Dialog", null);
8var outlineDialog = new DialogFragmentTab(
9 Java.Lang.Class.FromType(typeof(OutlineDialogFragment)), BookmarksTabLayout.TagTabOutline, null, "Outline", "Bookmarks Dialog", null);
10var userBookmarksDialog = new DialogFragmentTab(
11 Java.Lang.Class.FromType(typeof(UserBookmarkDialogFragment)), BookmarksTabLayout.TagTabBookmark, null, "User Bookmarks", "Bookmarks Dialog", null);
12tabs.Add(annotationsTab);
13tabs.Add(outlineDialog);
14tabs.Add(userBookmarksDialog);
15bookmarksDialog.SetDialogFragmentTabs(tabs);
16bookmarksDialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
17bookmarksDialog.Show(this.SupportFragmentManager, "bookmarks_dialog");
18bookmarksDialog.AnnotationClicked += (sender, e) =>
19{
20 bookmarksDialog.Dismiss();
21};
22bookmarksDialog.ExportAnnotations += (sender, e) =>
23{
24 // handle export annotations here
25 bookmarksDialog.Dismiss();
26};
27bookmarksDialog.OutlineClicked += (sender, e) =>
28{
29 bookmarksDialog.Dismiss();
30};
31bookmarksDialog.UserBookmarkClick += (sender, e) =>
32{
33 mPdfViewCtrl.SetCurrentPage(e.PageNum);
34 bookmarksDialog.Dismiss();
35};

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