B4A Library [Library] B4aGridView v3.80



Hi guys, B4AGridView is updated to v3.70.


1: GridView Demo
1: Library
1: PDF Explanations



A big thanks goes to ( Sergey Tarasevich - author of Universal Image Loader )

A thanks is always appreciated.


B4AGridView
Author:
Giuseppe Salvi
Version: 3.7

  • Fields:
    • Default As Typeface
      The default NORMAL typeface object.
    • Default_Bold As Typeface
      The default BOLD typeface object.
    • Monospace As Typeface
      The NORMAL style of the default monospace typeface.
    • Sans_Serif As Typeface
      The NORMAL style of the default sans serif typeface.
    • Serif As Typeface
      The NORMAL style of the default serif typeface.
    • Style_Bold As Int
      The default BOLD style int.
    • Style_Bold_Italic As Int
      The default BOLD ITALIC style int.
    • Style_Italic As Int
      The default ITALIC style int.
    • Style_Normal As Int
      The default NORMAL style int.
    Methods:
    • LoadFontFromAssets (file As String) As Typeface
      Create a new typeface from the specified font data from assets.
    • LoadFontFromFile (file As String) As Typeface
      Create a new typeface from the specified font data from sdcard.

  • Fields:
    • Center As ScaleType
      Center the image in the view, but perform no scaling.
    • Center_Crop As ScaleType
      Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image
      will be equal to or larger than the corresponding dimension of the view (minus padding).
    • Center_Inside As ScaleType
      Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the image
      will be equal to or less than the corresponding dimension of the view (minus padding).
    • Fit_Center As ScaleType
      Scale the image using CENTER.
    • Fit_End As ScaleType
      Scale the image using END.
    • Fit_Start As ScaleType
      Scale the image using START.
    • Fit_XY As ScaleType
      Scale the image using FILL.
    • Matrix As ScaleType
      Scale using the image matrix when drawing.

  • Fields:
    • CARDS As Int
      CARDS Effect = 2
    • CURL As Int
      CURL Effect = 3
    • FADE As Int
      FADE Effect = 12
    • FAN As Int
      FAN Effect = 9
    • FLIP As Int
      FLIP Effect = 5
    • FLY As Int
      FLY Effect = 6
    • GROW As Int
      GROW Effect = 1
    • HELIX As Int
      HELIX Effect = 8
    • PUZZLE As Int
      PUZZLE Effect = 16
    • REVERSE_FLY As Int
      REVERSE_FLY Effect = 7
    • REVERSE_TWIRL As Int
      REVERSE_TWIRL Effect = 15
    • SLIDE_IN As Int
      SLIDE_IN Effect = 14
    • STANDARD As Int
      Standard Effect = 0
    • TILT As Int
      TILT Effect = 10
    • TWIRL As Int
      TWIRL Effect = 13
    • WAVE As Int
      WAVE Effect = 4
    • ZIPPER As Int
      ZIPPER Effect = 11

  • Fields:
    • Text_Bottom_Inside As GravityEnum
      Text Bottom InSide
    • Text_Bottom_OutSide As GravityEnum
      Text Bottom OutSide
    • Text_Center_Inside As GravityEnum
      Text Center InSide
    • Text_Top_Inside As GravityEnum
      Text Top InSide
    • Text_Top_OutSide As GravityEnum
      Text Top OutSide

  • Fields:
    • AUTO_FIT As Int
      Creates as many columns as can fit on screen.
    • NO_STRETCH As Int
      Disables stretching.
    • STRETCH_COLUMN_WIDTH As Int
      Stretches the spacing between columns.
    • STRETCH_SPACING As Int
      Stretches columns.
    • STRETCH_SPACING_UNIFORM As Int
      Stretches the spacing between columns.

  • Fields:
    • Compress_Format_JPG As CompressFormat
      Compression Format JPG
    • Compress_Format_PNG As CompressFormat
      Compression Format PNG

  • PhotoGridView
    Events:
    • ItemClick (Position As Int, Value As Object)
    • ItemLongClick (Position As Int, Value As Object)
    • Ready ( As )
    • ShareItemClick (Value As Object)
    Methods:
    • AddImage (dir As String, file As String)
      Add an image from sdcard or AssetsDir at the end of the GridView
    • AddImageAt (index As Int, dir As String, file As String)
      Add an image from sdcard or AssetsDir to the desired position in the GridView
    • AddImageFromWeb (address As String)
      Add an image from web at the end of the GridView
    • AddImageFromWebAt (index As Int, address As String)
      Add an image from Web to the desired position in the GridView
    • AddThisView
      Adds view to this activity 100%x,100%y
    • ClearDiskCache
      Clears disk cache.
    • ClearMemoryCache
      Clears memory cache
    • DestroyEngine
      Stops ImageLoader and clears current configuration. Use this option on exit app.
    • GetArrayList As List
      Gets array.
    • GetCacheDir As String
      Returns application cache directory. Cache directory will be created on SD card
      <i>("/Android/data/[app_package_name]/cache")</i> if card is mounted and app has appropriate permission. Else -
      Android defines cache directory on device's file system.
      Return type: @return:Cache {@link File directory}.<br />
      <b>NOTE:</b> Can be null in some unpredictable cases (if SD card is unmounted)
    • GetImageListFromAssets (path As String, sort As Boolean) As List
      Get entire list of images stored in assets or sub-folder
      Examples:
      <code>
      Dim lv as ListView
      Dim l as list
      l.Initialize
      lv.Initialize("lv")
      Sub Menu_Click
      Activity.AddView(lv,0,0,100%x,100%y)
      l = GridView.GetImageListFromAssets("Here the Images folder stored in Assets")
      or
      l = GridView.GetImageListFromAssets(File.DirAssets)
      or
      l = GridView.GetImageListFromAssets("")
      For n = 0 To l.Size-1
      lv.AddSingleLine(l.Get(n))
      next
      End Sub
      </code>
    • GetIndividualCacheDir As String
      Returns individual application cache directory (for only image caching from ImageLoader). Cache directory will be
      created on SD card <i>("/Android/data/[app_package_name]/cache/b4AGridview-Images")</i> if card is mounted and app has
      appropriate permission. Else - Android defines cache directory on device's file system.
    • GetItem (position As Int) As String
      Returns Item
      Example:
      i.Bitmap=LoadBitmap("",g.GetItem(Position))
    • GetRealImagePath (filename As String) As String
      Returns the real path of the image
    • GoToWebsite (url As String)
      Go to web site by given an address
      Example:
      GoToWebsite("www.example.com")
      url:
    • Initialize (EventName As String)
      Initialize the object
    • Initialize2 (EventName As String, withCacheName As String)
      Initialize the object and set own cache directory
    • InitializeFromLayout (EventName As String, container As ViewGroup, Layout As String, LayoutID As String)
      Initialize the object from layout
    • PauseEngine
      Pause ImageLoader. All new load and display tasks won't be executed until ImageLoader is resumed.
      Already running tasks are not paused.
    • ResumeEngine
      Resumes waiting load and display tasks
    • SetArrayList (array As ArrayList)
      Sets array.
    • SetText (text As String)
      Sets the string value of the TextView.
    • SetText2 (index As Int, text As String)
      Sets the string value of the TextView.
    • ShareItemsTo (appName As String, item As String, subJect As String, message As String, shareTo As String)
      Share any items to ?
      app: name
      item:
      subJect:
      message:
      shareTo:
    • ShareTextUrlTo (subject As String, text As String, message As String, shareTo As String)
      Share any text to ?
      subject:
      text:
      message:
      shareTo:
    • ShowActionBarToShare (icons() As String)
      Sets the icons on action bar
      Example:
      Dim icons() As String = Array As String("gmail.png","email.png","gmx.png","dropbox.png","facebook.png","twitter.png","telegram.png","line.png")
      icons: as array
    • ShowFromAssets (path As String, sort As Boolean)
      Populate GridView from assets or assets/sub-folder
    • ShowFromBucket (path As String, sort As Boolean)
      Populate GridView from sdcard
    • ShowFromMediaStore (sort As Boolean)
      Populate GridView from media store images
    • ShowFromSdCard (dir As String, path As String, sort As Boolean)
      Populate GridView from sdcard
    • ShowFromWeb (webStrings() As String, sort As Boolean)
      Populate GridView from web
    • StopEngine
      Cancels all running and scheduled display image tasks.
      <b>NOTE:</b> This method doesn't shutdown if you set them.

      ImageLoader still can be used after calling this method.
    • TextBackGroundColor (red As Int, green As Int, blue As Int)
      Sets the background color for this view.
      <b>by default red = 0</b>
      <b>by default green = 0</b>
      <b>by default blue = 0</b>
    • TextColor2 (alpha As Int, red As Int, green As Int, blue As Int)
      Get or Sets Text Color - by default White
    • isPauseOnFling As Boolean
      Whether pause ImageLoader during fling
    • isPauseOnScroll As Boolean
      Whether pause ImageLoader during touch scrolling
    Permissions:
    • android.permission.INTERNET
    • android.permission.READ_EXTERNAL_STORAGE
    • android.permission.WRITE_EXTERNAL_STORAGE
    Properties:
    • CacheInMemory As Boolean [write only]
      Sets whether loaded image will be cached in memory.
    • CacheOnDisk As Boolean [write only]
      Sets whether loaded image will be cached on disk.
    • ColumnWidth As Int
      Get or Sets Specifies the fixed width for each column.
    • CompressFormat As BitmaCompression
      Get or Sets the known formats a bitmap can be compressed into [ JPG or PNG ]Sets the quality of a bitmap, that can be compressed. [ 0 = low -> 100 = high ]
      by default PNG
    • CompressQuality As Int
      Get or Sets the quality of a bitmap, that can be compressed. [ 0 = low -> 100 = high ]
      by default 100
    • DelayBeforeLoading As Int [write only]
      Sets delay time before starting loading task. Default - no delay.
    • FadeInTime As Int [write only]
      Duration of "fade-in" animation (in milliseconds)
      Whether animation should be played if image is loaded from network
      Whether animation should be played if image is loaded from disk cache
      Whether animation should be played if image is loaded from memory cache
    • Friction As Boolean
      Get or Sets the amount of friction applied to flings.
    • Gravity As Int [write only]
      Specifies the gravity within each cell.
    • HorizontalSpacing As Int [write only]
      Defines the default horizontal spacing between columns..
    • ItemHeight As Int
      Get or Sets the the size of the images will be displayed in thumbnail by default size is 480x320
    • ItemWidth As Int
      Get or Sets the the size of the images will be displayed in thumbnail by default size is 480x320
    • Length As Int [read only]
      Returns length
    • LoadFontFromAssets As String [write only]
      Loads a new Typeface from the specified font data.
    • LoadFontFromFile As String [write only]
      Loads a new Typeface from the specified font data.
    • MaxAnimationVelocity As Int
      Get or Sets max animation velocity.
    • NumColumns As Int
      Get or Sets the number of columns in the grid.
    • PauseOnFling As Boolean [write only]
      Whether pause ImageLoader during fling
    • PauseOnScroll As Boolean [write only]
      Whether pause ImageLoader during touch scrolling
    • ProgressBarIndeterminate As Boolean [write only]
      Change the indeterminate mode for this progress bar.
    • ProgressBarVisible As Boolean [write only]
      Set the enabled state of this view. - by default is trueChange the indeterminate mode for this progress bar.
    • RemoveAt As Int [write only]
      Removes the item at the specified location from this list.
    • ResetViewBeforeLoading As Boolean [write only]
      Sets whether image view will be reset before image loading start
    • RoundedBitmap As Boolean [write only]
      Can display bitmap with rounded corners. - by default is false
    • ScaleType As PhotoScaleTypes
      Controls how the image should be resized or moved to match the size of this ImageView.
      by default ScaleTypeFIT_XY
    • ScaleTypeForRounded As ScaleType [write only]
      Controls how the RoundedBitmap should be resized or moved to match the size of this ImageView.
      by default ScaleType.FIT_CENTER
    • Selection As Int
      Get or Sets the currently selected item.
    • SetBorderColor As Int [write only]
      Set the border Color - by default is transparent
    • SetBorderWidth As Int [write only]
      Set the border Width - by default is 0
    • SetCornerRadius As Int [write only]
      Set the corner Radius - by default is 0
    • SetImageOnFail As String [write only]
      Sets own icon on fail
    • SetImageOnLoading As String [write only]
      Sets own icon on loading
    • SetNoEffect As Boolean [write only]
      Can display bitmap with rounded corners.
      Show thumbnails with corner radius or oval. - by default is true
    • ShouldOnlyAnimateFling As Boolean
      Get or Sets should only animate fling.
    • ShouldOnlyAnimateNewItems As Boolean
      Get or Sets should only animate new item.
    • ShowMessageError As Boolean [write only]
      Set to true if you want to display an error message.
    • SimulateGridWithList As Boolean
      Get or Sets simulate grid with list.
    • SmoothScrollbarEnabled As Boolean [write only]
      When smooth scrollbar is enabled, the position and size of the scrollbar thumb is computed based on the number of visible pixels in the visible items.
    • StretchMode As StretchModeEnum
      Defines how columns should stretch to fill the available empty space, if any.
      Examples:
      GridView.StretchMode = GridView.StretchMode.STRETCH_SPACING
    • Tag As Object
      Get or Sets this view's tag.
    • TextBackGroundAlpha As Int
      Get or Sets alpha property of the view, as a value between 0 (completely transparent) and 255 (completely opaque).
      <b>by default alpha = 0</b>
    • TextBackGroundColor2 As String [write only]
      Sets the background color for this view.
      Example:
      TextBackGroundColor2("#88666666")
    • TextColor As Int
      Get or Sets Text Color - by default White
    • TextGravity As Int
      Get or Sets the horizontal alignment of the text that will be used.
    • TextLines As Int
      Get or Sets the TextView exactly this many lines tall.
    • TextPosition As TextPositionEnum
      Get or Sets the position alignment of the text that will be used.
      <b>param Text_Top_OutSide</b>
      <b>param Text_Top_Inside</b>
      <b>param Text_Center_Inside</b>
      <b>param Text_Bottom_Inside</b>
    • TextSize As Int
      Get or Sets Text Size - by default 14
    • TextStyle As Int [write only]
      Sets the style in which the text should be displayed.
    • TextTypeFace As TypefaceUtils
      Get or Sets the typeface and style in which the text should be displayed.
      Note that not all Typeface families actually have bold and italic variants,
      so you may need to use TextStyle(style) to get the appearance that you actually want.
    • TextVisible As Boolean
      Get or Sets the visibility of the text - by default is hide
    • TransitionDuration As Int
      Get or Sets transition duration.
    • TransitionEffect As TransitionEffect
      Get or Sets the desired transition effect.
    • Version As String [read only]
      Version of the library
    • VerticalSpacing As Int [write only]
      Defines the default vertical spacing between rows.
 

Attachments

  • GridView.jpg
    GridView.jpg
    92.4 KB · Views: 3,884
  • gridview.jpg
    gridview.jpg
    80.3 KB · Views: 3,462
  • B4AGridView_v3.70_Demo.zip
    337.7 KB · Views: 843
  • B4AGridView_v3.70_Lib.zip
    461.2 KB · Views: 464
  • B4AGridView_v3.70.pdf
    102.2 KB · Views: 598
  • B4AGridView_Lib_v3.80.zip
    408.7 KB · Views: 503
  • B4AGridView_Lib_v3.80_Fix.zip
    409.4 KB · Views: 920
Last edited:

lonleystar

Well-Known Member
Licensed User
Hi guys GridView has been updated to version 3.70, what's new:



//*********************************************************************************

added:

InitializeFromLayout("GridView",Activity,"main","gridView") (for this please have a look in the Maifest)

Friction (slow down the scroll)

AddThisView


ShowFromBucket (Depends On from new library B4AMediaBucket I'll upload till to night)

//*********************************************************************************

changed:

ShowText to TextVisible

//*********************************************************************************

important:
Work with Layout and as CustoView check it out.

minor bug fixed

tested on android 5.0.1, 6.0 and 7.1.1 samsung s4 tab1 tab2 tab10.1 and Huawei P8 Lite.

I uploaded 3 files a demo, library and a pdf
 

MarcoRome

Expert
Licensed User
Hi guys GridView has been updated to version 3.70, what's new:



//*********************************************************************************

added:

InitializeFromLayout("GridView",Activity,"main","gridView") (for this please have a look in the Maifest)

Friction (slow down the scroll)

AddThisView


ShowFromBucket (Depends On from new library B4AMediaBucket I'll upload till to night)

//*********************************************************************************

changed:

ShowText to TextVisible

//*********************************************************************************

important:
Work with Layout and as CustoView check it out.

minor bug fixed

tested on android 5.0.1, 6.0 and 7.1.1 samsung s4 tab1 tab2 tab10.1 and Huawei P8 Lite.

I uploaded 3 files a demo, library and a pdf
Great work ;)
Merry Christmas
 

aidymp

Well-Known Member
Licensed User
Well the first surprise is, IT WORKS! ;)

And the second one is it works very well! If i use it, I will donate! but first impressions of 3.70 are very good!

Thanks!

Aidy
 

lonleystar

Well-Known Member
Licensed User
Hi guys I forgot to say if U wish to Initialiize the GridView from layout You should write in the manifest example below:

B4X:
CreateResource(values, color.xml,

<resources>

    <color name="primary">#FF5722</color>
    <color name="primary_dark">#FF5722</color>
    <color name="sliddercolor">#50FF5722</color>
    <color name="back">#333333</color>

</resources>

)


to build your own gridview in the manifest as first you need this line below or U'll get an error

<it.giuseppe.salvi.gridview.library.core.gridview.GridViewCore



B4X:
CreateResource(layout, main.xml,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/sliddercolor"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="vertical" >

<it.giuseppe.salvi.gridview.library.core.gridview.GridViewCore
    android:id="@+id/gridView"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:cacheColorHint="#00000000"
    android:choiceMode="multipleChoice"
    android:columnWidth="100dp"
    android:drawSelectorOnTop="false"
    android:gravity="center"
    android:horizontalSpacing="2dp"
    android:listSelector="@android:color/black"
    android:numColumns="2"
    android:paddingLeft="1dp"
    android:paddingRight="1dp"
    android:paddingTop="2dp"
    android:stretchMode="columnWidth"
    android:verticalSpacing="2dp" />
 
</LinearLayout>

)


P.S

You can use any layout: ( LinearLayout, RelativeLayout, FrameLayout )

I wish you all a Merry Christmas

 
Last edited:

Ohanian

Active Member
Licensed User
Hi,

is it possible to add a ScrollChanged event to this lib?
 

Declan

Well-Known Member
Licensed User
Great Library, will definitely donate.
Two issues I cannot sort out.
I set ItemHeight / ItemWidth, but images are always square?
B4X:
    GridView.NumColumns = 3
    GridView.Itemwidth = 160dip
    GridView.ItemHeight = 210dip
    GridView.HorizontalSpacing = 50dip
    GridView.VerticalSpacing = 50dip
    GridView.Color = Colors.White
    GridView.SetBorderColor = Colors.White
    GridView.SetBorderWidth = 50dip
I need to read the filename of the image ("ugvuvu.jpg")
B4X:
Sub GridView_ItemClick(Position As Int, Value As Object)
    Log("Value: " & Value)
End Sub
gives me:
B4X:
Value: android.graphics.Bitmap@344ec3ea
 

Declan

Well-Known Member
Licensed User
Running V3.7, I get the following error.
Error is here:
B4X:
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    Dim files As List
    If Permission = rp.PERMISSION_READ_EXTERNAL_STORAGE Then
        files = File.ListFiles(File.DirRootExternal & "/eBuki/BooksImages") 'get all files in this folder
        For i = 0 To files.Size - 1
            Dim f As String
            f = files.Get(i)
            If f.ToLowerCase.EndsWith(".jpg") Then
                MyBookImages.Add(f)
                GridView.AddImageAt(i, File.DirRootExternal, "/eBuki/BooksImages/" & f)
                GridView.TextVisible = True
                GridView.SetText2(i, f) '<--------ERROR
            End If
        Next
    End If
End Sub

My Code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
    GridView.Initialize("GridView")
    GridView.AddThisView
    GridView.ShouldOnlyAnimateFling = True
    GridView.TransitionEffect = GridView.TransitionEffect.GROW
    GridView.ItemWidth = 320dip
    GridView.ItemHeight = 420dip
    GridView.HorizontalSpacing = 20dip
    GridView.VerticalSpacing = 50dip
    GridView.Gravity = Gravity.CENTER
    GridView.ColumnWidth = 160dip
    GridView.StretchMode = GridView.StretchMode.NO_STRETCH
    GridView.NumColumns = 3
    GridView.TransitionDuration = 400
    GridView.MaxAnimationVelocity = 300
    GridView.SimulateGridWithList = True
    GridView.ScaleType = GridView.ScaleType.Fit_Center
    GridView.CacheOnDisk = True
    GridView.CacheInMemory = True
    GridView.ProgressBarIndeterminate = False
    GridView.ProgressBarVisible = True
    GridView.Color = Colors.White
    GridView.SetBorderColor = Colors.White
    GridView.SetBorderWidth = 100dip
    MyBookImages.Initialize
  
    GridView.TextBackGroundColor2 = Colors.White
    GridView.TextBackGroundAlpha = 255
    GridView.TextLines = 1
    GridView.TextColor = Colors.Black'.LightGray
    GridView.TextPosition = GridView.TextPosition.Text_Bottom_OutSide
    GridView.TextSize = 20
    GridView.TextVisible = True

End Sub
Error:
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 78 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.ArrayList.add(int, java.lang.Object)' on a null object reference
    at it.giuseppe.salvi.gridview.library.core.PhotoGridView.SetText2(PhotoGridView.java:1251)
    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:753)
    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.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5631)
    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:959)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
 

lonleystar

Well-Known Member
Licensed User
Great Library, will definitely donate.
Two issues I cannot sort out.
I set ItemHeight / ItemWidth, but images are always square?
B4X:
    GridView.NumColumns = 3
    GridView.Itemwidth = 160dip
    GridView.ItemHeight = 210dip
    GridView.HorizontalSpacing = 50dip
    GridView.VerticalSpacing = 50dip
    GridView.Color = Colors.White
    GridView.SetBorderColor = Colors.White
    GridView.SetBorderWidth = 50dip
I need to read the filename of the image ("ugvuvu.jpg")
B4X:
Sub GridView_ItemClick(Position As Int, Value As Object)
    Log("Value: " & Value)
End Sub
gives me:
B4X:
Value: android.graphics.Bitmap@344ec3ea

Hi I think U shold use GetRealImagePath or GetItem
 

Marco Nissen

Member
Licensed User
Thanks, sorted.
how did you solve this ? I get the same error for the setText Method ..

Does anybody have an idea what's wrong?
urls is a list of image urls, and the images are loaded totally fine
however, I can't get the text to display

@lonleystar can you help?

B4X:
(NullPointerException) java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.ArrayList.add(int, java.lang.Object)' on a null object reference

B4X:
GridView.ShowFromWeb(urls,False)
j=0
For Each linkmap As Map In links
  Try
     Dim lname As String = linkmap.get("name")
     GridView.SetText2(j, lname)
  Catch
     Log("error" & LastException)
  End Try
  j=j+1
Next
 
Last edited:

Marco Nissen

Member
Licensed User
Hi guys I forgot to say if U wish to Initialiize the GridView from layout You should write in the manifest example below:
..
Unfortunately the demo app also doesn't work. I was hoping to download the demo app, and use it to place a comment below an image, but unfortunately after adding setText, it will crash with the error message ...

B4X:
GridView.SimulateGridWithList = True
GridView.ProgressBarIndeterminate = False
GridView.ProgressBarVisible = True
GridView.TextVisible=True
Try
    GridView.AddImageFromWeb("http://cdn4.spiegel.de/images/image-1098813-900_breitwand_180x67-lmhi-1098813.jpg")
    GridView.SetText("hello") 
Catch
    ToastMessageShow("issue " & LastException,True) 
EndTry

I would be more than happy to use this library, but there seems to be a major bug in setText, which prevents to use it.

Can you please provide a fix ?
I have a different implementation of a grid view which I did myself in my app, but I'd like to replace it with this library if possible.

Thanks
 

Marco Nissen

Member
Licensed User
It's the same error as above
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.ArrayList.add(int, java.lang.Object)' on a null object reference

I get it all the time .. let me know if you have a fix, it would be really super cool !
 

lonleystar

Well-Known Member
Licensed User
It's the same error as above
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'void java.util.ArrayList.add(int, java.lang.Object)' on a null object reference

I get it all the time .. let me know if you have a fix, it would be really super cool !

Hi just now I tried ShowFromWeb, AddImageFromWeb and AddImageFromWebAt work fine

did you check the image address maybe some address is null
 

Marco Nissen

Member
Licensed User
Hi just now I tried ShowFromWeb, AddImageFromWeb and AddImageFromWebAt work fine

did you check the image address maybe some address is null

Well, those methods are not the problem.

I can successfully display the image.

setText does not work.

As I described above, I modified the example that you provided to include "setText"

But: it creates the above error message.

I installed B4AGridView 3.70 and B4A 6.50

Any idea?
 
Top