Which android view to use to display book like structure - android

Given I have a large text that I want to display on screen, which is paginated; which android view should I use? Viewpager seemed like a good choice, but I don't know if viewpager scales well if you have something like 10000+ pages on low end devices.
Any help in the right direction is greatly appreciated.

Why not make a book-like experience, with some libraries like https://code.google.com/p/android-page-curl/

Viewpager by default only loads 3 pages at a time. Therefore it can be a good choice. However, you will need to create your own adapter for the viewPager.
I am guessing that the pages are stored in the file system. In that case it would be wise to create an object that can load the pages to the memory and pass it as argument to the adapter.

Related

Correct design for using the same data for different views

I am new in the corporate world & from design perspective please correct me if I am doing something wrong here
I am fetching images from Flickr API.
GOAL: Show these images in two different type of view, grid view and listview. Which can be switch through the slide.
So I am using a View pager with two fragments and both of these fragments has separate listeners. So when the response came from Flickr both of these listeners are notified.
In my opinion, this saves two times calling of REST API, but I am looking for even more efficient design or flow through which
Using single listener
Rest API should be called once
Result should be store (Just in ArrayList) and share to both of views
May not choosing two separate fragments
Avoid creating Adapter object two times
Image should be stored in cache
Any tweak or suggestions will be helpful a lot, please comment if you don't understand any part or whole question.
For above problem, the tweaking you are thinking is almost right. Other than below:
What I believe you must create two different adapters to have more control over different views. For example, you might want to show with scale type crop center for an image in list view but scale type center inside for an image in grid view. There might be the different type of thing you may want to perform. So, it's a good practice to make two different adapters, to make the code more manageable.
Again the same goes for the fragment, see if actions in both the fragments are same or can be done with single variable passing. Then only go with a single fragment.
Rest of the things are perfect.

Best way to create ListView for Android

I am beginner. I am looking for Tutorials of Swipe / Refresh / Listview with adapter which Data comes from Parser.com. I can't find in the web the suitable one!
I tried a lot of one but nothing work well.
Can you advice where can I get one is working well and easy to understand?
I work with Fragments, I don't know if it is correct way to work with theses fragment to create ListView?
Your help will be appreciated!
Regards,
Marwan
I'm typing here because I can't comment.
I learned how to use list view from
https://www.youtube.com/watch?v=BSZLqBWKTHw
and
http://developer.android.com/guide/topics/ui/layout/listview.html
As for using fragments, You can put them in fragments. I would do that if the fragment would be used in more than one activity or if you want make use of space in larger screens.

create tabbed view to display web pages

In my app I am making a web browser in which I want to show different pages in form of tabs. I want to create a view like this
But I have no idea how to do this. Need guidance regarding the components required.
Well the "simple" way to achieve this would be to create an adapter of some sort that overrides the getView() function to create a WebView
and return it as one of the items. The URL of this webview can be mapped to an array or cursor. Since a WebView is a very costly component, you will need to implement the ViewHolder pattern to ensure the webviews are recycled properly.
A lot more work is required to get the rounded corners plus the extra top features but hopefully this can get you started on the right track.

Two Custom ListViews inside an activity for larger displays

Android 2.3.3
I have an activity where I display "Device's Contacts" in my custom view(imageview, 3 textboxes, checkbox) inside a ListView. What I want to do is, display two listviews with both showing alternate contacts (Splitting the listview into two) side by side. This is because, I want to utilize space on landscape mode of larger displays.
I haven't seen many questions on SO and somewhere I have read that, this approach will mess up scrolling of listviews and will get messy.
So, can someone explain why/how would it get messy and is there another way to use the space in larger displays in my scenario.
Thanks.
This sounds like exactly what the Building a Dynamic UI with Fragments android tutorial was designed to address.
As #ooops mentions you will need to put each ListView within its own container. In the tutorial I linked to, they accomplished this by using 2 Fragment instances, each that loaded different content. Whether you copy their example and use the <fragment> tab (admitidly I don't remember which API level that works on) or use a different container like a regular LinearLayout you should be able to acomplish this easily.
You could do this, but each ListView should be in it's own container.
For examlple How to use multiple listviews in a single activity on android?
But be aware that #Rarw is more correct in the way of good programming practice. Fragments are recommended for such purpose.

Android: using viewfliper with dynamic no of slides, number of slides can vary

I need to implement an application which uses a sliding view (ViewFlipper) for one of its activity, this activity displays information stored on and array and passed from the previous activity via intent. The number of slides or tabs is expected to vary depending on the number of elements in the array. i.e for 4 elements in the array,we shall get 4 slides and when there is only 3, we have the same amount of slides displaying respective information accordingly.
Any idea on how to implement this, an example if possible? I am very new to android development. please help
Create an .xml file now implement a view flipper design the layout of how each pages work. I suggest using a relative layout and add those views inside the view flipper. Seems pretty basic now go search tuts on .xml, viewflippers, types of layout, textviews, and don't put questions here next time asking for answers. We are a community after all helping people with problems who actually tries to do something not for copy and paste people.
For this purpose it's best not to use the ViewFlipper, but instead use a ViewPager to which you can dynamically add 'subviews' (pages) using a PagerAdapter. ViewPager will provide performance benefits over ViewFlipper as it loads (and removes) pages on-demand (like a ListView).
Set-up of the ViewPager is in essence the same as setting up a ListView. You can use the ViewPager on Android <3.0 devices using the compatibility library.
Create your own class that extends PagerAdapter, and set mViewPager.setAdapter(mAdapter);. In your adapter, in the method instantiateItem() you will build your 'page' and add it to the parent with mViewPager.addView(newView);.
For a more detailed example of how to set-up a ViewPager see my answer here.

Categories

Resources