B4A Library Grid/Table and ListView Library

This library allows to create easely grids/tables and
from version 2.50
list views too!
Enjoy!
:)

The original post has been moved
http://www.b4x.com/android/forum/threads/grid-library.16381/page-10#post-168452"

Version 2.50 beta
- Added support for multiline rows

Version 2.51 beta
- Bug fixes

Version 2.52 beta
- Added Typeface support for rows and hedaer

Version 2.53
- Added SingleLine property for columns

sample code and usage hints can be found here
http://www.b4x.com/android/forum/threads/grid-library.16381/page-15#post-194602

Version 2.55
- Added object b4aActivityContext

Version 2.56
- Added and modified event hendlers
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-297198

Version 2.57
- Added Columns Builders
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-299406

Version 2.58
- Bug fixes

Version 2.59
- Added RowHeight for each column
- Added HeaderHeight for each column
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-304465

Version 2.60
- Added TouchX() and TouchY()
- Added FirstVisiblePosition() and LastVisiblePosition()
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-304905

Version 2.65
- Added Button Columns
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-306507

Version 2.67
- Added CellProps event
- Removed PropSetColor / PropSetTextColor
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-19#post-307490

Version 2.71
- Added OnSelectAllow event
- Added selection on row background
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-347618

Version 2.73
- Added OnRowProps event
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-349404

Version 2.76
- Fixed dubug log bug
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-375965

If you like my grid.
You can support the development.


 

Attachments

  • xnGridSample200beta.zip
    3.6 KB · Views: 2,052
  • xnGrid2xx_1.png
    xnGrid2xx_1.png
    77.2 KB · Views: 5,114
  • xnObjects267.zip
    75.7 KB · Views: 790
  • xnObjects272.zip
    87.2 KB · Views: 592
  • xnObjects273.zip
    87.5 KB · Views: 687
  • xnObjects276.zip
    87.2 KB · Views: 1,429
Last edited:

Discorez

Member
Licensed User
Longtime User
@discorez
i've compiled with no problems the sample project
with xnObject 1.67
i use jdk1.6.0_30

Mmmm... It isn't compiled...
The compiler shows a similar error :
Parsing code. 0.00
Compiling code. 0.01
Compiling layouts code. 0.00
Generating R file. Error
AndroidManifest.xml:22: error: Error: String types not allowed (at 'configChanges' with value 'keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize').
My version jdk 1.7.0_03 - may be this trouble is here?

if you want i can send the sample project again
please let me know
:)
Please, if it isn't difficult to you :)
 

stefanobusetto

Active Member
Licensed User
Longtime User
@discorez

hi
i've compiled the xnGridSample with jdk1.7.0_17
without any problem.
i've also tryed to recompile the xnObjects library
with jdk1.7.0_17.
everything ok.

please try to download and compile the xnGridSample project
:)
 

stefanobusetto

Active Member
Licensed User
Longtime User
Posted new version and updated sample code

Added ScrollBy ( x As int , y As int )
to scroll the grid of the specified number of horz and vert points

Added ScrollTo ( x As int , y As int )
to scroll the grid to the specified position in points

:)
 

miquelr

Member
Licensed User
Longtime User
click on header

I want to implement a sort algorithm but I can not find the xnGrid events documentation nowhere. Exist an even for detect a click on the header or the horizontal displacement when scroll?
 

stefanobusetto

Active Member
Licensed User
Longtime User
@miquelr
i've added support for header click
please download version 1.69

B4X:
Sub gg_header_click
    Msgbox ( "column = " & gg.HeaderClicked , "clicked on header" )
End Sub

@aviario
working on gravity

:):):)
 
Last edited:

bparent

Member
Licensed User
Longtime User
Convert this without xnTable as from Ver 1.6

Hello stefanobusetto,

i thank you for your effort.

Can i add a Row at Runtime?
Please look my code below:


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 gg As xnGrid
Dim tt As xnTable
End Sub

Sub Activity_Create(FirstTime As Boolean)
      ' 
      tt.Initialize ( Array As String ( "Anz" , "PLU" , "Name" , "Preis" ) )
      For r = 0 To 1
      tt.Append ( Array As String ( "a" & r , "b" & r , "c" & r , "12.50"  ) )
      Next

''Here I can add a new row without any problems
      tt.Insert ( Array As String ( "3" , "125"  , "Cola mit Eis 0,3" , "2.50"  ),0)
      tt.Insert ( Array As String ( "2" , "122"  , "Cola mit Fanta 0,3" , "2.50"  ),0)
      
      ' 
      gg.Initialize("gg")
'      gg.HeaderHeight=50
'      gg.RowEvenColor = Colors.Green
'      gg.RowOddColor = Colors.Red 
'      gg.Color = colors.DarkGray 
'      gg.SelectedEvenColor = Colors.Yellow 
      
   
   
   
      Dim c0 As xnGridCol
      Dim c1 As xnGridCol
      Dim c2 As xnGridCol
      Dim c3 As xnGridCol
      
      gg.RowHeight = 50dip
      c0.Initialize ( "Anz." , "Anz" , 50dip )
      c0.Gravity=Gravity.LEFT
      gg.Columns.Add ( c0 )

      c1.Initialize ( "PLU." , "PLU" , 50dip )
      gg.Columns.Add ( c1 )

      c2.Initialize ( "Speisename" , "Name" , 150dip )
      gg.Columns.Add ( c2 )
      
      c3.Initialize ( "€" , "Preis", 70dip)
      c3.Gravity=Gravity.RIGHT 
      gg.Columns.Add ( c3 )


      Activity.AddView ( gg , 0dip , 130dip , 400dip , 300dip )
      gg.GridCreate ( tt ) 
   
      Activity.LoadLayout("Test")
      
End Sub

'Here I would like to add a new row, but not happens
Sub Button1_Click
   tt.Insert ( Array As String ( "2" , "122"  , "Eistee 0,3" , "2.50"  ),0)
End Sub

How do I convert this code since xnTable is integrated in xnGrid? Several llines and methods are affected. Thanks.
 

stefanobusetto

Active Member
Licensed User
Longtime User
B4X:
If gg.InsertRow ( 3 , Array As String ( "new" , "new" , "new" , "new" ) ) Then
   Msgbox ( "ok" , "InsertRow" )
End If

B4X:
If gg.AppendRow ( Array As String ( "new" , "new" , "new" , "new" ) )Then
   Msgbox ( "ok" , "AppendRow" )
End If
:)
 
Last edited:

Brad

Active Member
Licensed User
Longtime User
Nice grid stef! One problem I see is when the .gridclear is called .rowcount does not reset to 0.
 

stefanobusetto

Active Member
Licensed User
Longtime User
Added vertical gravity support for cells
B4X:
   Dim cc(4) As xnGridCol

   cc(0).Initialize2 ( "Cod." , "cod" , 40dip , Gravity.TOP + Gravity.LEFT )
   gg.AppendCol ( cc(0) )

   cc(1).Initialize2 ( "Des." , "des" , 160dip , Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL)
   gg.AppendCol ( cc(1) )

      cc(2).Initialize2 ( "Grp." , "grp" , 160dip , Gravity.BOTTOM + Gravity.RIGHT )
   gg.AppendCol ( cc(2) )

   cc(3).Initialize2 ( "Other" , "other" , 360dip , Gravity.LEFT )
   gg.AppendCol ( cc(3) )
:)
 

aviario

Active Member
Licensed User
Longtime User
Hello, I downloaded the new version 1.71 of the date and xnObjects xnObjects.jar, xml is 27/03/2013
I set one of the headers in this way because I want the header and data center it put me to the left and puts it all on the left
cc (1). Initialize2 ("Off.", "des" 120dip, Gravity.CENTER_HORIZONTAL + Gravity.LEFT)
gg.AppendCol (cc (1))


I am attaching a picture of how it is and as it should be

un saludo
Paco
 

Attachments

  • xngrid.jpg
    xngrid.jpg
    55.3 KB · Views: 251

stefanobusetto

Active Member
Licensed User
Longtime User
hi
i'm not sure i've fully understood you question.

header and cells use the same gravity.
you can set vertical and horizontal alignment
for example
Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
or
Gravity.CENTER_VERTICAL + Gravity.TOP
:)
 

aviario

Active Member
Licensed User
Longtime User
hi
i'm not sure i've fully understood you question.

header and cells use the same gravity.
you can set vertical and horizontal alignment
for example
Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
or
Gravity.CENTER_VERTICAL + Gravity.TOP
:)

Hi,
We'd like have an independient Gravity for Header and another Gravity for cells of that column. For example, we want center text header, but for this column we want left align for cells(data).

Many thanks
 

Brad

Active Member
Licensed User
Longtime User
Found something else. When I attempt to save values that I changed, the values do not go into the correct columns. So for example, the variable newvalue1 would be inserted into the column for newvalue3.

Sample code I'm using
B4X:
grid1.SetValue(grid1.RowSelected,0,newvalue1)
grid1.SetValue(grid1.RowSelected,1,newvalue2)
grid1.SetValue(grid1.RowSelected,2,newvalue3)
 

stefanobusetto

Active Member
Licensed User
Longtime User
@brad
there are 2 methods in the grid
GridClear : deletes all the visual components of the gird
but does not delete the grid data

DeleteRows : deletes all the gird data
and repaints the grid ( actually calls GridClear )
:)
 

qsrtech

Active Member
Licensed User
Longtime User
Padding

HI, Great grid and I was wondering if it's possible to add some padding to the cells?
 
Top