B4J Library [B4X] [XUI] [B4XLib] SD_ShopListView

This new view allows you to have an ordered and distributed list of images (left) and their name, description and info (right)
Or you can view the images in grid (if the screen size allows it, otherwise in column) where there will be related images with the name just below
There is an add button and a close button that makes the visit invisible (mBase.Visible = False so to speak)
Note: In the asset file you must always put the empty.png file. The file can be found in the examples

NOTE: You can use this library for personal and commercial use. Include it in your projects.. Attention, even if it is a B4XLib library, it is not allowed to decompress it, modify it, change its name or redistribute it without the permission of the author

SD_ShopListView

Author:
Star-Dust
Version: 0.13
  • ShopListView
    • Events:
      • Add
      • Clicked (Pos As Int, ID As String)
    • Fields:
      • Animated As Boolean
      • mBase As B4XView
      • Tag As Object
    • Functions:
      • AddItem (ID As String, Image As B4XBitmap, Name As String, Description As String, Info As String)
        Add Item - with Image
      • AddItemAsync (ID As String, FileName As String, Name As String, Description As String, Info As String)
        Add Item - with local file image
      • AddItemNoImage (ID As String, Name As String, Description As String, Info As String)
        Add Item - Without image - The image can be set later asynchronously
      • AddToParent (MainPane As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
      • Base_Resize (Width As Double, Height As Double)
      • BringToFront
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • GetBase As B4XView
      • GetDescription (ID As String) As String
      • Getid (position As Int) As String
      • GetInfo (ID As String) As String
      • GetName (ID As String) As String
      • GrayBitmap (bmp As B4XBitmap) As B4XBitmap
      • ImageView (EventName As String) As B4XView
      • Initialize (Callback As Object, EventName As String)
      • Invalidate
      • isGrid As Boolean
      • RequestFocus
      • SendToBack
      • SetImage (ID As String, Image As B4XBitmap)
      • SetItem (ID As String, NewName As String, NewDescription As String, NewInfo As String)
      • SetVisibleAnimated (Duration As Int, Visible As Boolean)
      • size As Int
      • Snapshot As B4XView
      • TurnToGrid
      • TurnToList
    • Properties:
      • ButtonAddVisible As Boolean [write only]
      • ButtonExitVisible As Boolean [write only]
      • ButtonsGridListVisible As Boolean [write only]
      • Enable As Boolean
      • FilterFont As B4XFont ' Hint Font
      • FilterHint As String
      • FilterSearchText As String
      • FilterVisible As Boolean [write only]
      • Height As Int
      • Left As Int
      • Top As Int
      • Visible As Boolean
      • Width As Int
  • xSD_Scroll
    • Events:
      • ScrollChanged (X As Double, Y As Double)
      • ScrollChangedX (X As Double)
      • ScrollChangedY (Y As Double)
    • Fields:
      • PX As Double
      • PY As Double
    • Functions:
      • AddToParent (MainPane As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
        Create from codice
      • AddView (View As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
      • BringToFront
      • ClearAll
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map)
        Base type must be Object
      • FullScroll (Bottom As Boolean)
      • GetAllViewsRecursive As List
      • GetBase As B4XView
      • GetView (Index As Int) As B4XView
      • Initialize (Callback As Object, EventName As String)
      • IsInitialized As Boolean
      • LoadLayout (LayoutFile As String)
      • NativeObject As Object
      • NumberOfViews As Int
      • Parent As B4XView
      • RemoveAllViews
      • RemoveViewFromParent
      • RequestFocus
      • SendToBack
      • SetBitmap (bmp As B4XBitmap)
      • SetColorAndBorder (Backgroundcolor As Int, BorderWidth As Int, BorderColor As Int, BorderCornerRadius As Int)
      • SetColorAnimated (Duration As Int, FromColor As Int, ToColor As Int)
      • SetLayoutAnimated (Duration As Int, Left As Int, Top As Int, Width As Int, Height As Int)
      • SetPanelBitmap (bmp As B4XBitmap)
      • SetRotationAnimated (Duration As Int, Degree As Int)
      • SetVisibleAnimated (Duration As Int, Visible As Boolean)
      • Snapshot As B4XView
    • Properties:
      • Color As Int
      • Enable As Boolean
      • Height As Int
      • HorizontalBar As Boolean
      • Left As Int
      • Panel As B4XView [read only]
      • PanelHeight As Int
      • PanelWidth As Int
      • PositionX As Double
      • PositionY As Double
      • Tag As Object
      • Top As Int
      • VerticalBar As Boolean
      • Visible As Boolean
      • Width As Int


Video1.gif
Video2.gif
 

Attachments

  • iSample.zip
    110.3 KB · Views: 401
  • jSample.zip
    60.4 KB · Views: 442
  • aSample.zip
    8.3 KB · Views: 465
  • SD_ShopListView.b4xlib
    10.2 KB · Views: 284
Last edited:

netsistemas

Active Member
Licensed User
Longtime User
Attach a sample with error .
To use:
- Install
- Open and press upper button to DOWNLOAD IMAGEN from url (when finish, the app are close).
- Reopen app and press button VIEW.


for load with no error:
comment this code in loadimages:

B4X:
Private Sub LoadImages
    
    
    ShopListView1.ButtonAddVisible = False
    ShopListView1.ButtonExitVisible = False
    
    Dim Lista As List
    Lista = File.ListFiles(File.DirInternal)
    Lista.sort(True)
    Dim Fotos As Long
    
    For f = 0 To Lista.Size - 1
        Dim FN As String
        FN = Lista.Get(f)
        
        If FN.EndsWith("jpg") Then
            '    File.Delete(File.DirInternal,FN)
            ShopListView1.AddItem($"ID${f}"$ ,xui.LoadBitmap(File.DirInternal,FN ),FN,FN,$"Price: ${Rnd(20,100)}.00"$)
            Fotos = Fotos + 1
        Else
            Log(FN)
        End If
    Next
    
'    For i=0 To 17
'        ShopListView1.AddItem($"ID${i}"$ ,xui.LoadBitmap(File.DirAssets,$"${i}.jpg"$),$"Shoe model ${Chr(Rnd(65,90))}${Rnd(1000,9999)}"$,"Description shoes",$"Price: ${Rnd(20,100)}.00"$)
'    Next


    ShopListView1.Invalidate
    
    'dont do this... crack!
    'when?
    'COMMENT THIS LINEA to get NO eror.
    ShopListView1.TurnToList
End Sub


the error with line are uncommend is:

shoplistview_visualizegrid (java line: 2051)
jaa.lang.ArithmeticException: divide by zero
...
 

Attachments

  • ShopListDemo.zip
    6.3 KB · Views: 284

netsistemas

Active Member
Licensed User
Longtime User
i update the photos in internet (other zip) and now, all is ok.
no error are returned. (all photos are the same!!)
 

amorosik

Expert
Licensed User
Now library file is visible and downloadable

Using the library and the example in the first post, with the images of netsistemas (23 jpg files of 120 Kbytes each) I must note that it is impossible to use the list
In the sense that trying to scroll through the various articles, scrolling does not occur, without reporting any errors
While using the grid scrolling occurs correctly
 

netsistemas

Active Member
Licensed User
Longtime User
I view/have this error executing in one old table: (view logs in b4x)
(in me phone are ok)
Downsampling image due to lack of memory.
Downsampling image due to lack of memory.; 4
Downsampling image due to lack of memory: 8
....
and finally crack.
but, this ocurreme in other proyect.
memory problem!!

in other situation (i don't remeber) a view other error: division by cero.
 

Attachments

  • errpr.jpg
    errpr.jpg
    140.8 KB · Views: 253
Last edited:

netsistemas

Active Member
Licensed User
Longtime User
change the image load method , some like this:
B4X:
ShopListView1.AddItem($"ID${f}"$ ,xui.LoadBitmapResize(File.DirInternal,FN,150,150,True  ),FN,FN,$"Price: ${Rnd(20,100)}.00"$)

LoadBitmapResize instead of LoadBitmap(i put 150, but i don't know what is the ideal size)
 

Star-Dust

Expert
Licensed User
Longtime User
Now library file is visible and downloadable

Using the library and the example in the first post, with the images of netsistemas (23 jpg files of 120 Kbytes each) I must note that it is impossible to use the list
In the sense that trying to scroll through the various articles, scrolling does not occur, without reporting any errors
While using the grid scrolling occurs correctly
Note: In the asset file you must always put the empty.png file. The file can be found in the examples. If not inserted, the library crashes.
 

Star-Dust

Expert
Licensed User
Longtime User
change the image load method , some like this:
B4X:
ShopListView1.AddItem($"ID${f}"$ ,xui.LoadBitmapResize(File.DirInternal,FN,150,150,True  ),FN,FN,$"Price: ${Rnd(20,100)}.00"$)

LoadBitmapResize instead of LoadBitmap(i put 150, but i don't know what is the ideal size)
It is not necessary to automatically resize.
Your example does not crash if you enter empty.png. But slow down a lot if you put the list.

At the moment I cannot establish the reason for this excessive memory absorption.
Your original request was a grid, only use it with grid until I can diagnose the problem
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.07
  • FilterVisible As Boolean (Only Write)
  • Fix Bugs
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Star-Dust,
How I know the filter editText parameter name? How can I edit Label of filter to be my language?
Please answer to me.(You're one of my Idols,I would like to be good at coding alike you ,but I'm not.)

Best Regards,
Theera
 

swamisantosh

Member
Licensed User
Longtime User
Hi Star-Dust, I getting this error in B4j, it works fine with B4A
B4J Version: 9.30
Parsing code. (0.09s)
Java Version: 8
Building folders structure. (0.02s)
Compiling code. Error
Error compiling program.
Error description: Unknown member: textsize
Error occurred on line: 861
T.TextSize=14
Word: textsize
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.08
  • fix bugs B4j
  • Added FillterHint As String ' you can customize the Hint text for the filter
  • FilterFont As B4XFont ''you can customize the Font Hint-text for the filter
 

Theera

Well-Known Member
Licensed User
Longtime User
Hi Star-Dust,
I would like to disturb you ,how do I know parameter of edittext as filter. it will be completed my learning code tutorial how tranfer parameter between APP1 and APP2.
I can't change filter in edittext 's box.
I hope your kindness help me learning code.

Best Regards,
Theera
 

netsistemas

Active Member
Licensed User
Longtime User
Surely the developer offers you a better solution.
But you can try to access the controls that are embedded through code similar to this
B4X:
    'this make NO VISIBLE  controls,'
    ShopListView1.GetBase.GetView (5) .Visible = False
    ShopListView1.GetBase.GetView (4) .Visible = False
    ShopListView1.GetBase.GetView (0).Visible  = False
    
    'may be somenthin like this'
    control =  ShopListView1.GetBase.GetView (5)    'or 4 or 3 or 2...'
    'and then:
    control.property = somthing
    'controls.text = ""
    'etc...
 

Star-Dust

Expert
Licensed User
Longtime User
Hi Star-Dust,
I would like to disturb you ,how do I know parameter of edittext as filter. it will be completed my learning code tutorial how tranfer parameter between APP1 and APP2.
I can't change filter in edittext 's box.
I hope your kindness help me learning code.

Best Regards,
Theera
In the next update you will be able to access the filter field.
 

Theera

Well-Known Member
Licensed User
Longtime User
In the future,If we set FilterSearchText =ProductA+ProductB and then it can show all of them(Product A and Porduct B). I' m sorry my English.
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.11
  • Fix Bugs
 
Top