Leave a Comment:
31 comments


wait , theirs two file of
details.xml , on this example , how this work ??




do you know how can I make a button that I have added to xml on the 1st fragment work or open a new page
Reply
Hello, thank you very much for the tutorial to add the buttons on each fragment you may use:
public class DetailFragment extends Fragment {

after that you can add the usual button code, however you have to be careful how the “intent” is defined
Reply
THANK YOU!!!
Your Tutorial is so great!
I didn’t understand it for years of development!!!
THANKS for sharing this simple tutorial with us!
You are the best, love you!!
Thank you, again! I am so happy now!
Reply

This is very good, however when I change the orientation of my phone the app crashes. Anyone have any ideas why? Here is the logcat:
12-24 21:09:30.411: D/dalvikvm(18639): newInstance failed: no ()
12-24 21:09:30.421: D/AndroidRuntime(18639): Shutting down VM
12-24 21:09:30.421: W/dalvikvm(18639): threadid=1: thread exiting with uncaught exception (group=0x40028a00)
12-24 21:09:30.451: E/AndroidRuntime(18639): FATAL EXCEPTION: main
12-24 21:09:30.451: E/AndroidRuntime(18639): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.viewpagerexample/com.example.viewpagerexample.ViewPagerExample}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.jacoblever.view.pager.example.MenuFragment: make sure class name exists, is public, and has an empty constructor that is public
Thanks
Reply
Hi, very nice example, but how can I zoom and pan the images in this viewpager?
Thanks in advance!
Regards,
Katrina



[…] guess this tutorial might be helpful. It employs Android’s […]
Reply
Thank you so much. I have been struggling like anything for the past 5 days to try this kind of example.
Great post.
Reply
Hi,
If i create i listview in one of the fragment and I want to refresh the listView after the fragment is created. how do i can do this. Thanks in advance.

i still got error ,
uncaught exception (group=0x4001d800)
can you help me?
Reply
Hi guys,
Thanks Sushant, for your sample.
It didn’t work at first but I managed to get it working.
I also included an image to replace that drawable.thumb I couldn’t find
For anyone asking for the complete source, here follows:
http://www.scottx.net/android_samples/ViewPagerExample.zip
I have this sample which is almost everything I want to do but lacks zoom:
http://developer.android.com/training/displaying-bitmaps/index.html
And I also have this great sample which has pinch-zoom:
https://github.com/sephiroth74/ImageViewZoom
Now modified by me with a double tap listener zooming to image at 100%:
http://www.scottx.net/android_samples/ImageViewTouch.zip
offtopic: The girl in the photo included in this sample is my neighbour 🙂
Now what I would like to do is either put the ImageViewTouch on a Pageviewer like the sample explained on this page so a user can swipe the image to see the next photo keeping the zooming capabilites, or use the first sample from Google but with zooming.
Could anyone give a little help here?
Thank you so much 🙂
Ricardo Santos



Hey , thanks for this. I have 2 problem, hope you can help. I want the pager to go from left to right(not sure how to do that) and when the screen orientation changes it closes out the page. Can you please help me with these 2 issue. Thanks in advance
Reply
Nice post. I like the example.
In ImageFragment.java “imageResourceId” should not be defined as final.
