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.basic4ppc.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.basic4ppc.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: 1,619
  • xnGrid2xx_1.png
    xnGrid2xx_1.png
    77.2 KB · Views: 4,508
  • xnObjects267.zip
    75.7 KB · Views: 483
  • xnObjects272.zip
    87.2 KB · Views: 329
  • xnObjects273.zip
    87.5 KB · Views: 415
  • xnObjects276.zip
    87.2 KB · Views: 1,038
Last edited:

imgsimonebiliato

Well-Known Member
Licensed User
Hi Stefano,
you can delete only the selected rows from the grid?
Thanks

Here it is the code:

B4X:
Private grid As xnGrid
Sub grid_CellClick ( Col As Int, Row As Int )
grid.RowDelete(Row)
End Sub
 

BluSky76

Member
Licensed User
Thanks for the reply.

I do not want to delete a single line but with a command to delete all selected rows. If the grid contains 100 rows and 20 are selected I want to delete a command only the twenty selected.

example
grid.RowDeleteSelect

Thank you
 

Sberla

Active Member
Licensed User
Hello !
Is it possible to set the textcolor and of text size of columns instead of rows ?

Thanx
 

stefanobusetto

Active Member
Licensed User
Use the "CellProps" event
:)

B4X:
Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
If aCol = 1 Then
   aProps.TextColor = Colors.Red
   aProps.BackGroundColor = Colors.Gray
End If

If aCol = 1 Then
   If aRow = 1 Then
      aProps.BackGroundColor = Colors.Green
   End If
End If
End Sub
 

GaryK4

Member
Licensed User
Use the "CellProps" event
:)

B4X:
Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
If aCol = 1 Then
   aProps.TextColor = Colors.Red
   aProps.BackGroundColor = Colors.Gray
End If

If aCol = 1 Then
   If aRow = 1 Then
      aProps.BackGroundColor = Colors.Green
   End If
End If
End Sub

I am new to this library. It looks very promising.
I created a test program and the CellProps event is giving a java error.
"java.lang.IllegalStateException: This method must only be called as part of a callback while a frame is in progress."

My phone is a new Note 8 - Android 7.1.1

What I am trying to accomplish is as follows,
When I long click a row or based on a db record, set that row to a color.
The original SetPropColor would have been perfect for my needs.

-----------------
I changed the program from GridCreate2(False) to GridCreate and the java error went away.
Now, I can get it to do what I want.
-----------------
 
Last edited:

GaryK4

Member
Licensed User
Sorry,
could you list a list of all the grid events?

thanks

Hi,

I am just in the evaluation process. The current events are select, long_select and CellProps.

As I said in my edited message, I got the program to work.
GridCreate2(False) was creating a java error.
GridCreate works!

I'm not sure what the difference is, but I will go with what is working.
 

stefanobusetto

Active Member
Licensed User
The horizontal and vertical scroll bars are automatically display.
You can enable the FastScroll option
B4X:
Grid.FastScroll = True ;
:)
 

GaryK4

Member
Licensed User
I added the following code to the provided sample program.

Sub gg_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
Log (aCol & " - " & aRow)
End Sub

There are 3 rows with 4 columns.
When I touch a cell, It lists all rows and columns. Not just the one that I selected?

Am I doing something wrong?
 

stefanobusetto

Active Member
Licensed User
The CellProps is called every time a cell is painted.
You can set the cell properties assigning vaules to the aProps object.
The aCol , aRow and aValue are passed to provide information on the
painting cell.
What do you want to do?
:)
 

GaryK4

Member
Licensed User
The CellProps is called every time a cell is painted.
You can set the cell properties assigning vaules to the aProps object.
The aCol , aRow and aValue are passed to provide information on the
painting cell.
What do you want to do?
:)

I want to long click on a cell and change it value and background color. Basically, a toggle column.
 

imgsimonebiliato

Well-Known Member
Licensed User
how to set the color of a row based on the value of one column?

Hi @jrat you need to implement this method:


B4X:
Dim grid as xnGrid

Sub grid_CellProps ( aCol As Int, aRow As Int, aValue As String, aProps As xnGridCellProps )
Dim v As String
v = grid.GetValue2 ( aRow, "VALUE" )

If v = "0" Then aProps.BackGroundColor = Colors.Red
If v = "1" Then aProps.BackGroundColor = Colors.Green

End Sub
 
Top