0

Currently I am working with navigation drawer and fragments. my goal is to convert a pdf to Android app. the pdf has around 600 pages and for each page I am creating a fragment which will open with corresponding page number item from navigation drawer. is it normal to work with 600 fragmenta and its layout file or does it take up too much resources? What is the best practice to achieve something like this?

Pannam T
  • 389
  • 7
  • 20
  • why do you need 600 Fragments? creating one and changing its content wouldn't work? – mmark Mar 03 '16 at 00:35
  • Every page has different sets of Images and not in a systematic order. It is like an interactive manual hence changing just the content is complicated for me. – Pannam T Mar 03 '16 at 00:52
  • Keep it as pdf, convert the content to HTML, maybe into fragments if you auto-generate them. Fragments are not meant to be a page of content. They are the stuff around the content. – zapl Mar 03 '16 at 01:42

1 Answers1

0

Fragment is a piece of interface. Not piece of data!

So you can make one fragment for content and one for navigation and then just switch data in content fragment. Content fragment can contain Listview with pdf pages or single ImageView for single page (and this ImageView can be changed programmatically) or something else.

Here is some links:

Creating a ListView with custom list items programmatically in Android - no xml list item layout

Change Image of ImageView programmatically‎ Android

Community
  • 1
  • 1
Alexandr Shutko
  • 1,857
  • 2
  • 20
  • 27
  • By this do you mean I have to understand the concept of x y coordinates in android and move the image view etc accordingly hence reducing the load on the app ? could you suggest any keyword i can search fir tutorial as I do not know what to look for. – Pannam T Mar 05 '16 at 03:28
  • As I understand you have a pdf with 600 pages and want to display it as scrollable list. To do this you can create RecycleView and custom adapter loading pdf pages on demand to display in RecyclerView. This can be done in fragment or even in activity. – Alexandr Shutko Mar 05 '16 at 03:33
  • my goal is to create an interactive manual animating images and texts as the user clicks on the next button. With the suggestions I have received I now have just a couple of fragments and layout and I am placing the views programmatically. i have extracted all the image file from the pdf. But as the images are supposed to be scattered (to make it interactive) I am having difficulty positioning them as they need to be in specification position. Hence I ask what should I look into to get an understanding? – Pannam T Mar 05 '16 at 04:20
  • I added some links to answer. Read about LlistView or RecycleView and ImageView. The goal is to have a single layout with content and navigation areas and switch content to wanted page. – Alexandr Shutko Mar 05 '16 at 04:27