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

Anser

Well-Known Member
Licensed User
Longtime User
Hi,

Just sharing some information.

As per my tests, this library when used along with the Library Spinner Wheel - Vertical and Horizontal https://www.b4x.com/android/forum/t...izontal-1-feb-new-lib-files-in-post-17.62723/
Gives the following compilation error due to the incompatibility in the nineoldandroids used.
B4X:
B4A version: 5.80
Parsing code.    (0.12s)
Compiling code.    (0.36s)
Compiling layouts code.    (0.02s)
Generating R file.    (0.90s)
Compiling generated Java code.    (2.45s)
Convert byte code - optimized dex.    Error
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/nineoldandroids/animation/Animator$AnimatorListener;
    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:122)
    at com.android.dx.dex.file.DexFile.add(DexFile.java:161)
    at com.android.dx.command.dexer.Main.processClass(Main.java:615)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:570)
    at com.android.dx.command.dexer.Main.access$2(Main.java:546)
    at com.android.dx.command.dexer.Main$2.processFileBytes(Main.java:514)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:537)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:449)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:236)
    at com.android.dx.command.dexer.Main.run(Main.java:206)
    at com.android.dx.command.dexer.Main.main(Main.java:179)
    at com.android.dx.command.Main.main(Main.java:103)
1 error; aborting

Both the libraries cannot be used together in a project. Individually both the libs works fine, the problem occurs only when both the libs are used together in a project.

I had posted the error message in another thread in the Questions section and the following is the reply from Erel

The library author should update the library and move out the nineoldandroids classes to a jar which will then be referenced with @DependsOn.


Regards
Anser[/QUOTE]
 

frenkipi

Member
Licensed User
Longtime User
Hello, is there a way to use image slider combined with picasso library (link)? When I combine these two... I add another picasso.jar and picasso.xml in library folder and I get this error

LogCat connected to: efcd5d80
--------- beginning of system--------- beginning of main~i:Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.NoSuchMethodError: No virtual method load(Ljava/lang/String;)Lcom/squareup/picasso/RequestCreator; in class Lcom/squareup/picasso/Picasso; or its super classes (declaration of 'com.squareup.picasso.Picasso' appears in /data/app/uk.co.martinpearman.b4a.picassoexample-1/base.apk)
at com.daimajia.slider.library.SliderTypes.BaseSliderView.bindEventAndShow(BaseSliderView.java:199)
at com.daimajia.slider.library.SliderTypes.TextSliderView.getView(TextSliderView.java:25)
at com.daimajia.slider.library.SliderAdapter.instantiateItem(SliderAdapter.java:81)
at com.daimajia.slider.library.Tricks.InfinitePagerAdapter.instantiateItem(InfinitePagerAdapter.java:54)
at com.daimajia.slider.library.Tricks.ViewPagerEx.addNewItem(ViewPagerEx.java:832)
at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:982)
at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:914)
at com.daimajia.slider.library.Tricks.ViewPagerEx.onMeasure(ViewPagerEx.java:1438)
at android.view.View.measure(View.java:18596)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18596)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:447)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2897)
at android.view.View.measure(View.java:18596)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2248)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1306)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1548)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Copying updated assets files (2)
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Target_Success Tag=ActivityBackground
Target_Success Tag=ImageView
** Activity (main) Pause, UserClosed = true **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/daimajia/slider/library/R$attr;
at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:167)
at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:163)
at AndroidSlider.SliderLibrary.Slider.innerInitialize(Slider.java:145)
at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
at AndroidSlider.SliderLibrary.Slider.Initialize(Slider.java:134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:748)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:343)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:897)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:831)
at b4a.example.callsubutils._tmr_tick(callsubutils.java:224)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:340)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.daimajia.slider.library.R$attr" on path: DexPathList[[zip file "/data/app/b4a.example-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 33 more
Suppressed: java.lang.ClassNotFoundException: com.daimajia.slider.library.R$attr
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 34 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Error occurred on line: 125 (Main)
java.lang.RuntimeException: Object should first be initialized (Slider).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:703)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:337)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
An error occurred:
(Line: 134) For Each fi As String In filelist
java.lang.RuntimeException: Array not expected...
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/squareup/picasso/Picasso;
at com.daimajia.slider.library.SliderTypes.BaseSliderView.bindEventAndShow(BaseSliderView.java:194)
at com.daimajia.slider.library.SliderTypes.TextSliderView.getView(TextSliderView.java:25)
at com.daimajia.slider.library.SliderAdapter.instantiateItem(SliderAdapter.java:81)
at com.daimajia.slider.library.Tricks.InfinitePagerAdapter.instantiateItem(InfinitePagerAdapter.java:54)
at com.daimajia.slider.library.Tricks.ViewPagerEx.addNewItem(ViewPagerEx.java:832)
at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:982)
at com.daimajia.slider.library.Tricks.ViewPagerEx.populate(ViewPagerEx.java:914)
at com.daimajia.slider.library.Tricks.ViewPagerEx.onMeasure(ViewPagerEx.java:1438)
at android.view.View.measure(View.java:18596)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18596)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:728)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:464)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1489)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChild(ViewGroup.java:5797)
at android.view.ViewGroup.measureChildren(ViewGroup.java:5773)
at anywheresoftware.b4a.BALayout.onMeasure(BALayout.java:64)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1435)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:721)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:612)
at android.view.View.measure(View.java:18596)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5827)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:430)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2897)
at android.view.View.measure(View.java:18596)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2248)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1306)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1548)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1191)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6642)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
at android.view.Choreographer.doCallbacks(Choreographer.java:590)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5951)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.in
Message longer than Log limit (4000). Message was truncated.
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
Copying updated assets files (1)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = true **
** Service (starter) Destroy **
Copying updated assets files (1)
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
0 = Item #1
** Activity (main) Pause, UserClosed = false **
** Activity (podrobnosti) Create, isFirst = true **
** Activity (podrobnosti) Resume **
** Activity (podrobnosti) Pause, UserClosed = true **
** Activity (main) Resume **
Current page: 1
** Activity (main) Pause, UserClosed = false **
** Service (starter) Destroy **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
Current page: 1
Current page: 2
Current page: 3
Current page: 2
Current page: 1
Current page: 0
** Activity (main) Pause, UserClosed = false **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
POINTS_COUNT = 9
** Service (httputils2service) Create **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
30 = Item #1
** Activity (main) Pause, UserClosed = false **
** Activity (podrobnosti) Create, isFirst = true **
** Activity (podrobnosti) Resume **
** Activity (podrobnosti) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **

I have created image slider and picasso imageviewer in separate project and they all works.

Regards!
 

desof

Well-Known Member
Licensed User
Longtime User
Is it possible to insert into an existing layout already with other controls?
How is it possible ?
 

Asim A Baki

Active Member
Licensed User
Longtime User
Is it possible to insert into an existing layout already with other controls?
How is it possible ?
yes you can

B4X:
Dim Slider As Slider
    Slider.Initialize("Slider")
  
    Activity.AddView(Slider,0dip,0dip,50%x,50%y)
 

desof

Well-Known Member
Licensed User
Longtime User
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

And what would be the burden to do it through files not from the WEB?
 

Asim A Baki

Active Member
Licensed User
Longtime User
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

And what would be the burden to do it through files not from the WEB?
I'm not sure if I understand your point but maybe this is your requirement

Slider.AddSlide(fi , "file:" & path )
 

peacemaker

Expert
Licensed User
Longtime User
Is it possible do not start playing ? Just start for manual sliding.
After Start - the first image is slided very fast, and then long loading the next one, that is for test is the same as the first one. Never loaded the second the same one...
But how to just slide manually ?
 

peacemaker

Expert
Licensed User
Longtime User
Is it possible to manually set the needed slide ?
 

peacemaker

Expert
Licensed User
Longtime User
Clear... So, here all depends on the original JAR lib that is wrapped ?
And no additional possibility to control the slides (only manual sliding, set needed one, click) ?
 

peacemaker

Expert
Licensed User
Longtime User
When some Java lib is wrapped for B4A - can new functions be added into the B4A lib ?
For this one lib "manual sliding from the needed position; image tap event" are interesting.
 

peacemaker

Expert
Licensed User
Longtime User
This means that it needs to find some alternative slider lib...
Thanks, Don.
 

Alexander Stolte

Expert
Licensed User
Longtime User
Hey, my head is steaming...

How can i create Slider via Loop?

In my example is only one picture of 3 in the Slider.

B4X:
Sub Activity_Create(FirstTime As Boolean)

    Activity.LoadLayout("frm_diashow")
    Slider.Initialize("Slider")
   Activity.AddView(Slider,0,0,100%x,100%y)
  
    picsize  = chat.picture.Size
   For i = 0 To picsize -1
        Dim filename As String = "mypicture.jpg"
        Dim dir As String = File.DirDefaultExternal
        'Main.reqManager.BytesToImage(chat.picture.Get(0))
        SavePictureToFile(chat.picture.Get( i), dir, filename)
      Dim bm2 As BitmapExtended
        Dim bm As Bitmap
        Dim bm3 As Object
        bm =   LoadBitmapSample(File.DirDefaultExternal,   "mypicture.jpg",    100%x,100%y)
      Dim path As String =File.Combine(File.DirDefaultExternal  , "mypicture.jpg" )

        bm=bm2.rotateBitmap(bm,90)
  
        bm3 = Main.reqManager.ImageToBytes( bm)
        Dim filename As String = "mypicture.jpg"
        Dim dir As String = File.DirDefaultExternal
    
        SavePictureToFile(bm3, dir, filename)

       Slider.AddSlide("Momentcat"  , "file:" & path )
  
    Next
  
    Slider.SetTransition(Slider.SLIDER_TRANSITION_FlipHorizontal)
    'SLIDER_TRANSITION_FlipHorizontal
    '.SLIDER_TRANSITION_Tablet
    Slider.Delay=2000
    Slider.Start
            End Sub
 

robsonRC

New Member
Licensed User
Longtime User
Hi there is an error occurring when initializing the Slider.Initialize ("Slider")


B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 35 (Main)
android.view.InflateException: Binary XML file line #61: Error inflating class com.daimajia.slider.library.Tricks.InfiniteViewPager
    at android.view.LayoutInflater.createView(LayoutInflater.java:633)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:743)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:173)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:167)
    at com.daimajia.slider.library.SliderLayout.<init>(SliderLayout.java:163)
    at AndroidSlider.SliderLibrary.Slider.innerInitialize(Slider.java:145)
    at anywheresoftware.b4a.objects.ViewWrapper.Initialize(ViewWrapper.java:65)
    at AndroidSlider.SliderLibrary.Slider.Initialize(Slider.java:134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at b4a.example.main.afterFirstLayout(main.java:102)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:739)
 
Top