B4A Library Image Slider wrapper (daimajia.AndroidImageSlider)

Hi
This is my first experience with Library wrappers

Below is the wrapper for daimajia.AndroidImageSlider
from https://github.com/daimajia/AndroidImageSlider

687474703a2f2f7777332e73696e61696d672e636e2f6d773639302f36313064633033346a773165677a6f7236366f6a64673230393530666b6e70652e676966



simple to use, it is very simple features as well, I'll post here the source code for the wrapper in case someone wants to help enhancing the wrapper

to use the wrapper
1- Extract the "res" folder to your any path
2- Extract the "jar1.zip" and "jar2.zip" attachments to your android additional library folder
3- Add android-support-v4.jar to your android additional library folder
4- Create a new project
5- Goto the Libraries Manager and check AndroidSlider library
6- Add the line below to Project Attributes region
B4X:
#AdditionalRes: YOUR-RES-FOLDER-PATH, com.daimajia.slider.library
7- Add Slider object to the Globals sub
B4X:
Dim Slider As Slider
8- replace the Activity_create sub with the following code
B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    Activity.LoadLayout("1")
     Slider.Initialize("Slider")
   
    Activity.AddView(Slider,0dip,0dip,100%x,100%y)
'   
    Slider.AddSlide("Hannibal", "http://static2.hypable.com/wp-content/uploads/2013/12/hannibal-season-2-release-date.jpg")
    Slider.AddSlide("Big Bang Theory", "http://tvfiles.alphacoders.com/100/hdclearart-10.png")
    Slider.AddSlide("House of Cards", "http://cdn3.nflximg.net/images/3093/2043093.jpg")
    Slider.AddSlide("Game of Thrones", "http://images.boomsbeat.com/data/images/full/19640/game-of-thrones-season-4-jpg.jpg")
   
    Dim filelist As List = File.ListFiles(File.DirDefaultExternal  )
   
    For Each fi As String In filelist
        Dim path As String =File.Combine(File.DirDefaultExternal  , fi)
        If fi.LastIndexOf (".JPG")>0 Or fi.LastIndexOf (".png")>0  Then        
            Slider.AddSlide(fi , "file:" & path )
            
        End If
       
    Next
    Slider.SetTransition(Slider.SLIDER_TRANSITION_Fade)
    Slider.Delay=5000
    Slider.Start
End Sub
 

Attachments

  • jar1.zip
    400.6 KB · Views: 1,304
  • jar2.zip
    204.2 KB · Views: 1,150
  • AndroidSliderImage-SourceEclipse.zip
    93.3 KB · Views: 989
  • ImageSlideshowExample.zip
    8.8 KB · Views: 1,066
  • res.zip
    5.2 KB · Views: 1,055

cambopad

Active Member
Licensed User
Longtime User
Thanks you for sharing this awesome lib! This is really good to showcase our photos.
 

andyr00d

Member
Licensed User
Longtime User
I'm getting a crash running your example project in release and debug mode... I have placed the files where they should go and there are no errors before I compile?

B4X:
java.lang.IllegalAccessError: Method 'void android.support.v4.view.PagerAdapter.registerDataSetObserver(android.database.DataSetObserver)' is inaccessible to class 'com.daimajia.slider.library.Tricks.ViewPagerEx' (declaration of 'com.daimajia.slider.library.Tricks.ViewPagerEx' appears in /data/app/b4a.example-1/base.apk)
 

Asim A Baki

Active Member
Licensed User
Longtime User
I'm getting a crash running your example project in release and debug mode... I have placed the files where they should go and there are no errors before I compile?

B4X:
java.lang.IllegalAccessError: Method 'void android.support.v4.view.PagerAdapter.registerDataSetObserver(android.database.DataSetObserver)' is inaccessible to class 'com.daimajia.slider.library.Tricks.ViewPagerEx' (declaration of 'com.daimajia.slider.library.Tricks.ViewPagerEx' appears in /data/app/b4a.example-1/base.apk)
You need to have the right android-support-v4.jar added to your lib folder, the right file size is 758727KB length so I couldn't attach to the post but look for the file in the internet with the same size
 

phukol

Active Member
Licensed User
Longtime User
Thank you for the great library. Just want to ask what should i do if i want to use the images inside DirAssets? how should i go about in calling them?
 

Asim A Baki

Active Member
Licensed User
Longtime User
Thank you for the great library. Just want to ask what should i do if i want to use the images inside DirAssets? how should i go about in calling them?
I tried it before but looks like the uploading of assets to DirAssets cause the images to have a different header, I even tried to open the images by android album but it didn't work
 

phukol

Active Member
Licensed User
Longtime User
Thanks Asim, i really wish it could be possible because i do not see any difference when the images are from online (theyre just downloaded to phone right?) and from internal phone resources.
 

Asim A Baki

Active Member
Licensed User
Longtime User
Thanks Asim, i really wish it could be possible because i do not see any difference when the images are from online (theyre just downloaded to phone right?) and from internal phone resources.

this protion of code adds images from the phone, if I understand you right, but the DirAssets specially which it's files are added from the B4X designer doesn't work

B4X:
 Dim filelist As List = File.ListFiles(File.DirDefaultExternal  )
  
    For Each fi As String In filelist
        Dim path As String =File.Combine(File.DirDefaultExternal  , fi)
        If fi.LastIndexOf (".JPG")>0 Or fi.LastIndexOf (".png")>0  Then       
            Slider.AddSlide(fi , "file:" & path )
           
        End If
      
    Next
 

phukol

Active Member
Licensed User
Longtime User
Thanks Asim, from the bottom of my heart here in the Philippines, salamat. I just want to know a better sliding image alternative aside from the slidingpanels that i can use ....
 

Johan Schoeman

Expert
Licensed User
Longtime User
Hi, I'm getting an error

B4X:
java.lang.NoSuchFieldError: com.daimajia.slider.library.R$attr.SliderStyle

on compilation of your example, any advise please...
I think you are missing this step in post #1.....?

1- Extract the "res" folder to your any path

B4X:
#AdditionalRes: YOUR-RES-FOLDER-PATH, com.daimajia.slider.library
 
Last edited:

Blue.Sky

Active Member
Licensed User
Longtime User
@Asim A Baki Excellent
Thank you for sharing this library
ImageChanged Event does not work
What is the reason?

B4X:
Sub Slider_ImageChanged(index As Int)
    Log("ImageChanged")
End Sub
 

Asim A Baki

Active Member
Licensed User
Longtime User
@Asim A Baki Excellent
Thank you for sharing this library
ImageChanged Event does not work
What is the reason?

B4X:
Sub Slider_ImageChanged(index As Int)
    Log("ImageChanged")
End Sub
Actually I didn't implement the events, I just made what I needed for the time being, and I have posted the source code, just in case someone may help in improving the wrapper and re-post in the forum
 

cwkoomy

Member
Licensed User
Longtime User
** Activity (main) Pause, UserClosed = true ** how to use .sorry, im newbie
 

Anser

Well-Known Member
Licensed User
Longtime User
Good work @Asim A Baki

This library seems to be very useful. Most of the apps available in the PlayStore seems to have used this kind of ImageSlider View to show sliding images in their apps in one way or other.

Unfortunately, this lib, the only ImageSliderView lib available that can be used in B4A does not support Click event.

  1. Has anyone here modified the source to support click event ?
  2. Will this view support display of Image from a table's Blob column ie without writing the file to the device's File.DirInternal/File.External. For eg
    Slider.AddSlide("Test", BlobColumnData )
 
Top