Some test text!

Search
Hamburger Icon

Xamarin / Guides

Display & customize list container in Xamarin

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:

Bookmarks dialog

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:

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

using pdftron.PDF.Tools.Utils;

var bookmarksDialog = pdftron.PDF.Dialog.BookmarksDialogFragment.NewInstance();
bookmarksDialog.SetPdfViewCtrl(mPdfViewCtrl);
List<DialogFragmentTab> tabs = new List<DialogFragmentTab>();
var annotationsTab = new DialogFragmentTab(
    Java.Lang.Class.FromType(typeof(AnnotationDialogFragment)), BookmarksTabLayout.TagTabAnnotation, null, "Annotations", "Bookmarks Dialog", null);
var outlineDialog = new DialogFragmentTab(
    Java.Lang.Class.FromType(typeof(OutlineDialogFragment)), BookmarksTabLayout.TagTabOutline, null, "Outline", "Bookmarks Dialog", null);
var userBookmarksDialog = new DialogFragmentTab(
    Java.Lang.Class.FromType(typeof(UserBookmarkDialogFragment)), BookmarksTabLayout.TagTabBookmark, null, "User Bookmarks", "Bookmarks Dialog", null);
tabs.Add(annotationsTab);
tabs.Add(outlineDialog);
tabs.Add(userBookmarksDialog);
bookmarksDialog.SetDialogFragmentTabs(tabs);
bookmarksDialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
bookmarksDialog.Show(this.SupportFragmentManager, "bookmarks_dialog");
bookmarksDialog.AnnotationClicked += (sender, e) =>
{
    bookmarksDialog.Dismiss();
};
bookmarksDialog.ExportAnnotations += (sender, e) =>
{
    // handle export annotations here
    bookmarksDialog.Dismiss();
};
bookmarksDialog.OutlineClicked += (sender, e) =>
{
    bookmarksDialog.Dismiss();
};
bookmarksDialog.UserBookmarkClick += (sender, e) =>
{
    mPdfViewCtrl.SetCurrentPage(e.PageNum);
    bookmarksDialog.Dismiss();
};

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.

Get the answers you need: Chat with us