B4A Library AHViewPager library - Sliding panels now perfect

Discussion in 'Additional libraries, classes and official updates' started by corwin42, Jan 18, 2012.

  1. corwin42

    corwin42 Expert Licensed User

    This library is a B4A implementation of the ViewPager object provided by the compatibility class from google. With this library it is possible to add sliding panels to your apps.

    AHPageContainer - This object is a container for the pages of the AHViewPager. You should add Panels to this object.

    AHViewPager - This is the main object which provides the sliding panels.

    All the Tabs objects are deprecated now. You can use them but I don't enhance them anymore. For nice looking Tabs please use the DSTabLayout object of the DesignSupport library.
    Alternatively you can use the TabStripViewPager.


    Installation:
    • From V3.00 on the library requires B4A 6.0 or later.
    • This library depends on the Android Support library so you need to install the Android Support repository in the Extras section with SDK Manager.
    • Copy the AHViewPager.xml and AHViewPager.jar files to your additional libraries folder.
    Example project:

    For an example project for this library see the Design Support Library.

    Version History:

    1.00:
    - initial version

    1.01:
    - Added AHViewPagerFixedTabs object for a fixed tab indicator
    - Fixed a bug that it was impossible to get the canvas of a panel which was added to the container (It was impossible to display charts on a page)
    - Example for AHViewPagerFixedTabs tab indicator

    1.02: (Never released)
    - Fixes problem with tab height (Line is now always on the bottom)

    1.03:
    - Fixes problem with Line sometimes not updating correctly on Android 4.0+
    - Fix UppercaseTitle property

    2.0:
    - Complete Rewrite of the Swipey tabs code to fix some bugs with newer android versions.

    2.01:
    - New property for the AHViewPager object: PagingEnabled - Enables or disables paging for the ViewPager.

    2.02:
    - New events PageScrolled and PageScrollStateChanged (with SCROLLSTATE constants)
    See post 227 for details

    2.20:
    - Use raiseEventfromUI() in most events
    - New SupportTabs object
    - New SupportTitles object
    - Support for Designer (as a Custom View)
    - some minor internal changes and bug fixes

    2.21:
    - Use raiseEvent() for PageCreated and PageDestroyed event again to prevent double UI refreshes
    - Added @RaiseSynchronousEvents annotation to GotoPage() (to make it better compatible with rapid debugger.

    3.00:
    - Support for Designer Custom Properties.
    - Uses maven repository to access support library. (B4A 6.0 or later required)

    Attention: V2.20 has an API change which makes the ViewPager incompatible with older versions. The AHPageContainer parameter is removed from the Initialize() method. Initialize2() has the old signature. If you use Initialize() (or add the View to the Designer as a custom view) then you have to set the container object with ViewPager.PageContainer = <YourContainer>

    The examples use the old Initialize method, so they are broken. I was too lazy to fix them because I recommend the tab indicator from the Design Support library for a nice looking Material Design app.
     

    Attached Files:

    Last edited: Jun 23, 2016
  2. moster67

    moster67 Expert Licensed User

    Thank you Markus :sign0188:

    I like the look and feel about it. I tried your example also in landscape-mode and it works great.

    This will definitely be useful.
     
    Last edited: Jan 18, 2012
  3. susu

    susu Well-Known Member Licensed User

    Thank you Marcus! It's very useful for my e-book project :D
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Looks great! Thank you for sharing.
     
    luke2012 likes this.
  5. quasimidi

    quasimidi New Member Licensed User

    Awesome, thanks for your hard work!
     
  6. joseluis

    joseluis Active Member Licensed User

    Many thanks! this is something very very nice to have :sign0098:
     
  7. hackhack

    hackhack Active Member Licensed User

    That looks very good.

    (Now to see if i can figure it out :D )
     
  8. NJDude

    NJDude Expert Licensed User

    Absolutely AWESOME!!, thank you for sharing.

    EDIT: I have created a simplified project which uses this awesome lib along with layouts created with the designer.
     

    Attached Files:

    Last edited: Jan 18, 2012
  9. hackhack

    hackhack Active Member Licensed User

    Good example there NJDude :sign0098:
     
  10. splatt

    splatt Active Member Licensed User

    Great work Marcus. Superbly smooth. Thank you.
     
  11. bluedude

    bluedude Well-Known Member Licensed User

    I love it, great work!
     
  12. bluedude

    bluedude Well-Known Member Licensed User

    Problem on Galaxy Nexus

    Hi,

    I tried to use it on the Galaxy Nexus but the menu items in the top action bar are gone.

    The manifest features below target sdk:

    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>

    On all other apps. this works but the page viewer seems to kill menus.

    Cheers,
     
  13. dealsmonkey

    dealsmonkey Active Member Licensed User

    Thankyou for this library :icon_clap:
     
  14. Smee

    Smee Well-Known Member Licensed User

    Great Library Marcus.

    Thanks for your work i definitely see a use for it

    :sign0188:
     
  15. bluedude

    bluedude Well-Known Member Licensed User

    Action bar is not showing on Icecream Sandwich

    Hi,

    I have been doing some testing and indeed menu's will not show on Galaxy Nexus when target sdk = 14. This means it cannot work with the actionbar.

    Only when target = 11 it will work because it shows the menu options in the bottom. This means the actionbar is disabled.

    So there seems to be a conflict although I love this library.

    Attached a screenshot and you see, no action bar and no menu option in the bottom.
     

    Attached Files:

  16. bluedude

    bluedude Well-Known Member Licensed User

    Solved

    Well,

    Created a new project and now it seems to be ok.
     
  17. bluedude

    bluedude Well-Known Member Licensed User

    Solved

    Well,

    Created a new project and now it seems to be ok.
     
  18. corwin42

    corwin42 Expert Licensed User

    Hmm, perhaps this solution from Erel will fix it completely?
     
  19. bluedude

    bluedude Well-Known Member Licensed User

    Have tried that, didn't work for me. Now it seems to work.
     
  20. billmoultrie

    billmoultrie Member Licensed User

    Billmoultrie

    Hi

    I tried your example on an HTC wildfire but got the following error:

    Compiling code. 0.02
    Generating R file. 0.00
    Compiling generated Java code. Error
    B4A line: 57
    container.Initialize
    javac 1.6.0_23
    src\de\amberhome\viewpagerexample\main.java:243: cannot access android.support.v4.view.PagerAdapter
    class file for android.support.v4.view.PagerAdapter not found
    mostCurrent._container.Initialize(mostCurrent.activityBA);
    ^
    1 error
    Any ideas

    Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice