B4A Library [Library] B4aGridView v3.80

Dave O

Well-Known Member
Licensed User
Longtime User
Hi there,

Any plans to add drag-and-drop to your gridview library?
 

Dave O

Well-Known Member
Licensed User
Longtime User
Moved from North America to Wellington 8 years ago, and love it here. Our daughters grew up here before going to Vancouver for uni.

Will keep an eye on your gridview, thanks!
 

Serinter

Member
Licensed User
Longtime User
I think this grid and your work is very impressive.
I tested it and have some issues about it:

1. I have read in this thread that this library should work with android 2 or higher
I tried with ZTE Skate android Custom ROM v.2.3.7 and apk is unbootable.

LG-P970 android v. 4.0.3 and Google ASUS Nexus7 android v. 5.0.2 works well, but I have problems with setText
and SetText2

2. You should update sample code for the latest version of the library.
With the example of version 3.20 and the latest version (3.50), several things must be changed to avoid errors.

3. If I set .ShowText = True in Activity_Create or before populate the grid, the
apk throws an error and suddenly stops

4. I could not find a method to empty the grid, or operate any attempt proposed in this same thread.
There should be a method as "Gridview.Clear".
Without it, I think the grid loses much functionality and is not very useful.

5. In all devices I have problems with this library when trying to put text to images.

I want to add text to images, but the problem is that every time I scroll
both upwards and downwards, the texts are incorrect and unexplained change in each scroll.


I'm doing something wrong or is it an error?

Modifying the example to suit the latest version of the library:
(For example, in d_Click Sub, but same in others subs)

B4X:
Sub d_Click

    GridView.ShowFromMediaStore(False)
'    GridView.Selection = posSelected
    Activity.Title = "G.Salvi - Items = " & GridView.Length & " -  Width = " & GridView.ItemWidth&" | Height = "&GridView.ItemHeight

    Dim x As Int
    For x=0 To GridView.Length-1
        GridView.SetText2(x,"Picture " & (x+1))
    Next

    GridView.ShowText = True
End Sub

Try it and see text changes...

Adding items in loop by .AddImage, .AddImageAt, .AddImageFromWeb, .AddImageFromWebAt does not work either.

I tried changing caches boolean values, and nothing changes at all.

Can anybody help me, please? A working sample?

I apologize for my bad english. Thanks in advance.
 
Last edited:

lonleystar

Well-Known Member
Licensed User
Longtime User


Hi Serinter, the library work fine with android 2.3.6 just tested it on my old tab 7.

The commands AddImage, AddImageAt, AddImageFromWeb, AddImageFromWebAt also tested and work fine.

U've to use ShowText = True before to populate the text like below.

Let me know.


B4X:
Sub d_Click
    GridView.ShowText = True

    GridView.ShowFromMediaStore(False)

    Activity.Title = "G.Salvi - Items = " & GridView.Length & " -  Width = " & GridView.ItemWidth&" | Height = "&GridView.ItemHeight

    Dim x As Int

    For x=0 To GridView.Length-1

        GridView.SetText2(x,"Picture " & (x+1))

    Next
End Sub
 

Serinter

Member
Licensed User
Longtime User
Hi again lonleystar.

ZTE Skate (android 2.3.7) unbooteable app log:

LogCat connected to: skate
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


** Activity (main) Create, isFirst = true **


library.core.GridViewActivityWrapperInitialize2 (java line: 132)
java.lang.NoSuchMethodError: android.widget.AbsListView.setAdapter
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper.Initialize2(GridViewActivityWrapper.java:132)
at it.giuseppe.salvi.gridview.library.core.GridViewActivityWrapper.Initialize(GridViewActivityWrapper.java:115)
at it.giuseppe.salvi.gridview.main._activity_create(main.java:372)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
at it.giuseppe.salvi.gridview.main.afterFirstLayout(main.java:100)
at it.giuseppe.salvi.gridview.main.access$100(main.java:17)
at it.giuseppe.salvi.gridview.main$WaitForLayout.run(main.java:78)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)


at android.app.ActivityThread.main(ActivityThread.java:3835)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:622)
at dalvik.system.NativeStart.main(Native Method)

On Doogee DG350 Pixels (android v. 4.2.9), LG P970 (android v. 4.0.3) and Nexus 7 (android v. 5.1 updated today) I'm still having problems trying to add text to images.

Attached screenshots shows the problem:

First Screen, attached Image 1 apparently shows ok.


Scrolling down, In attached Image 2:
Picture 7 shows "Picture 1", Picture 9 shows "Picture 2" and Picture 10 shows "Picture 1"


Scrolling up, In attached Image 3:
Picture 1 shows "Picture 6", Picture 2 shows "Picture 1" and so on...


Everytime I scroll up or down, text changes and don't match with their corresponding picture.

I'm getting crazy and don't figure out where the problem is or what I'm doing wrong...

Any clue? I need advice / help, please!
 

lonleystar

Well-Known Member
Licensed User
Longtime User
Hi guys, B4AGridView is updated to v3.60 What's new:

Update the engine.

------------------------------

Fix:

GridView.CompressFormat -> PNG work well now.

------------------------------

Added Event:

ShareItemClick

------------------------------

Added:

TransitionEffect
Get or sets an effect

Example:

TransitionEffect = TransitionEffect.CARDS

STANDARD -> is flat effect

Effects:

STANDARD, GROW, CARDS, CURL
WAVE, FLIP, FLY, REVERSE_FLY
HELIX, FAN, TILT, ZIPPER
FADE, TWIRL, SLIDE_IN
REVERSE_TWIRL, PUZZLE

------------------------------
Added:

TransitionDuration
Give the duration in milliseconds to the animation

------------------------------

Added:

MaxAnimationVelocity

Give maximum speed in milliseconds for animation

------------------------------

Added:

ShouldOnlyAnimateNewItems

Animate the item only Once
value true : false

------------------------------

Added:

ShouldOnlyAnimateFling

Animate flayng
value true : false

------------------------------

Added:

SimulateGridWithList

Simulate grid with list
value true : false

------------------------------

Added:

ShowActionBarToShare -> Min sdk 11

Example:
B4X:
Sub Activity_Create(FirstTime As Boolean)


   'give exactly these names to png stored in assets as described in the array below.

   'The png size must be Min 64x64 or Max 128x128

   Dim icons() As String = Array As String("gmail.png","email.png","gmx.png","dropbox.png","facebook.png","twitter.png","telegram.png","line.png")

   GridView.ShowActionBarToShare(icons)

End Sub
------------------------------

Added:

ShareItemsTo -> [ ShareItemsTo(appName,item,"Subject Here","Message Here","Title Here") ]

Share any items to android-gmail, twitter, facebook, telegram, line, whatsapp, android-mail, dropbox, gmx-mail for Deutsch, etc,etc.

Click on any item and then choose from actionbar which one you'd like to share.

Example:
B4X:
Sub Globals

   Dim posSelected As Int

End Sub

Sub GridView_ItemClick(Position As Int, Value As Object)

   posSelected = Position

End Sub

Sub GridView_ShareItemClick(Value As Object)


   Dim share As String = GridView.GetItem(posSelected)  -> From sdcard, assets, web

   ShareItemsTo(Value,share,"Subject Here","Message Here","Title Here")

   or

   ShareItemsTo("",share,"Subject Here","Message Here","Title Here")


End Sub
------------------------------

Added:

ShareTextUrlTo

Share any text or URL

Example:
B4X:
Sub Button1_Click

   Share any URL

   GridView.ShareTextUrlTo("Subject Here","http://www.salvigiuseppe.altervista.org","Message Here","Title Here")

   GridView.ShareTextUrlTo("Subject Here","https://lh4.googleusercontent.com/-Z4zGiC5nWdc/URqvBdEwivI/AAAAAAAAAbs/ZRZR1VJ84QA/s1024/Sin%252520Lights.jpg","Message Here","Title Here")

   Share any Text

   GridView.ShareTextUrlTo("Subject Here","Any text U wish to share here","Message Here","Title Here")

End Sub
------------------------------

Added:

GoToWebsite

Opens the browser giving it an address
B4X:
Sub Button1_Click

   GridView.GoToWebsite("http://www.salvigiuseppe.altervista.org")

End Sub
------------------------------

Added:

GetIndividualCacheDir

Returns individual application cache directory (for only image caching from ImageLoader).
Cache directory will be created on SD card ("/Android/data/[app_package_name]/cache/b4AGridview-Images").

B4X:
ToastMessageShow(GridView.GetIndividualCacheDir,True)

------------------------------

Added:

GetCacheDir

Returns application cache directory.
Cache directory will be created on SD card ("/Android/data/[app_package_name]/cache").
B4X:
ToastMessageShow(GridView.GetCacheDir,True)
------------------------------

Added:

GetRealImagePath

Returns the exact path of the image.
B4X:
Sub GridView_ItemClick(Position As Int, Value As Object)
   Dim item As String = GridView.GetItem(Position)
   ToastMessageShow(GridView.GetRealImagePath(item),True)
End Sub


the library is comiled with jdk1.7.0_80 and android-22 platform

I'm sorry i forgot to upload the icons

put the icons in files folder
 

Attachments

  • ICONS_PNG.zip
    154.8 KB · Views: 304
Last edited:

Scott Bartgis

Member
Licensed User
Longtime User
Hi everyone... using 3.60, my extremely simple test app is hanging on GridView.Initialize("GV").

My code:
Log("A")
GridView.Initialize("GV")
Log("B")

I get "A", but never get "B". The unfilered logs show:

A
threadid=1: stack overflow on call to Ljava/util/AbstractList;.<init>:V
method requires 4+20+4=28 bytes, fp is 0x57061318 (24 left)
expanding stack end (0x57061300 to 0x57061000)
Shrank stack (to 0x57061300, curFrame is 0x570613b8)
Exception thrown (Ljava/lang/StackOverflowError while throwing internal exception (Ljava/io/FileNotFoundException

I'm not sure what file it is looking for.
 

lonleystar

Well-Known Member
Licensed User
Longtime User


Hi Scott, can U post a little example because I dont understand thi A and B. Would be better little example to find the error U get.
 

Scott Bartgis

Member
Licensed User
Longtime User
I did include some code, but I did not tag it. The use of "A" and "B" is a debugging technique to show where a program hangs. The system is logging the A and executing the Initialize, but not ever logging the B. That means the Initialize is hanging because execution never gets to log the "B". That is the entire content of the Sub Activity_Create.

I believe the main error is:
Exception thrown (Ljava/lang/StackOverflowError while throwing internal exception (Ljava/io/FileNotFoundException)

B4X:
Sub Globals
   Dim GridView As PhotoGridView
End Sub

Sub Activity_Create(FirstTime As Boolean)
   Log("A")
   GridView.Initialize("GV")
   Log("B")
End Sub
 

Scott Bartgis

Member
Licensed User
Longtime User
Also, if it helps, I get the same error and crash of the program from B4APhotoPager and B4AGalleryView. Extremely simple program:

Exception thrown (Ljava/lang/StackOverflowError) while throwing internal exception (Ljava/io/FileNotFoundException)

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim PP As PhotoPager
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    PP.Initialize("")

End Sub
 

lonleystar

Well-Known Member
Licensed User
Longtime User



Hi Scott, U'd use PP.Initialize("PP") instead of PP.Initialize("").
 

Scott Bartgis

Member
Licensed User
Longtime User
I wondered if you might say that, but it does not appear to make any difference. I wouldn't expect a problem since the string compare won't throw an error for FileNotFound.

Even with PP.Initialize("PP") it is the same result. It always dies/crashes with the FileNotFound error. Even your examples crash instantly with the error. The device is a Sibo (WonderMedia) 7" In-Wall Tablet used for home automation. Android 4.1.1.

http://geekland.co/7-Android-40-Wall-Mounted-Tablet-with-POE-GK-VIA-E002.htm
 

lonleystar

Well-Known Member
Licensed User
Longtime User


Hi Scott, I really dont know. Itested it old Tab 2.3.6, Tab2 4.1.2, Tab Note 2 10.1 and S4 5.0.2 and work well.

The Example is to old and doesnt support the new GridView.

Can U post Your code or send via email so I give a look and try to find the problem?
 

Shahid Saeed

Active Member
Licensed User
Longtime User
Hi @lonleystar, I have tried the version 3.60 and getting the following error:

B4X:
java.lang.StackOverflowError


    at java.util.AbstractList.<init>(AbstractList.java:376)
    at java.util.ArrayList.<init>(ArrayList.java:81)
    at java.lang.Throwable.<init>(Throwable.java:66)
    at java.lang.Throwable.<init>(Throwable.java:94)
    at java.lang.Exception.<init>(Exception.java:47)
    at java.io.IOException.<init>(IOException.java:44)
    at java.io.FileNotFoundException.<init>(FileNotFoundException.java:42)
    at android.content.res.AssetManager.openAsset(Native Method)
    at android.content.res.AssetManager.open(AssetManager.java:315)
    at android.content.res.AssetManager.open(AssetManager.java:289)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:310)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)


    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
    at it.giuseppe.salvi.gridview.library.core.adapter.GridViewAdapterWrapper.BsW2qaSU4g(SourceFile:313)
Message longer than Log limit (4000). Message was truncated.
 

Scott Bartgis

Member
Licensed User
Longtime User
I have posted the .b4a file. As I said, it is extremely simple. The routine fails on GridView.Initialize("GridView") with a file not found error.

Shahid has the FileNotFound exception as well, though he has some further logging which may be useful.

Does the library call for any files to exist in particular locations? Some assets maybe?
 

Attachments

  • GridView_3.60_Test.zip
    1.1 KB · Views: 196

lonleystar

Well-Known Member
Licensed User
Longtime User

Hi Scott, with my simple demo work fine i get no error not with initialize and not with anything else.

anyway I'll make a video and post it to show that it work fine.
 

Scott Bartgis

Member
Licensed User
Longtime User
I believe you that it is working on your devices, but what about the same FileNotFound error Shahid reported?
 

lonleystar

Well-Known Member
Licensed User
Longtime User


Hi Shahid, did U put in the Files folder the icons ICONS_PNG.zip I posted in to the post #288? if not download it and put it in the Files folder this icons is used when U call ShowActionBarToShare.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…