1

I am working on the printing custom file of Android, and I have some doubts in developer website of PrintedPdfDocument

// open a new document
   PrintedPdfDocument document = new PrintedPdfDocument(context,
     printAttributes);
// start a page
   Page page = document.startPage(0);
// draw something on the page
   View content = getContentView();
   content.draw(page.getCanvas());
// finish the page
   document.finishPage(page);
   . . .

What does the getContentView mean? I think I need to write the function body by myself, but I am not sure what is view mean? Can anyone help?

newszer
  • 440
  • 1
  • 4
  • 23

1 Answers1

1

Yeah. This method needs to be written unless you're working within a PopupWindow or GuidedActionsStylist.ViewHolder. These two has their own getContentView method supplied.

Basically, what this method does or intending to do is to provide you the root(or content) view of window.

Refer to this if you're writing this code under an Activity and implement your getContentView accordingly. Refer to this if you're using Fragment.

Community
  • 1
  • 1
fluffyBatman
  • 6,524
  • 3
  • 24
  • 25