Android Question B4XTable Questions - Getting RowID from checkbox / button click

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I have been able to add a Checkbox and Button to my table but when I get to the last page
there is only 1 row of data and yet each line has a checkbox and button - need to hide them and restore moving to another page

1583518807745.png


Last Page

1583518838013.png


When I click on a cell the Cell Clicked routine passes the Col ID and Row ID.

But when I click on my CheckBox or Button the CheckBox / Button routine gets called how do I get the RowID so I know what data I am dealing with.

And something I noticed is that if I click on the space around the checkbox the cell clicked routine gets called. I would prefer to have the checkbox routine called no matter where I click in the box

SORRY for so many questions - I am sure I will get the hang of this once get it working better.
 

Mahares

Expert
Licensed User
Longtime User
And something I noticed is that if I click on the space around the checkbox the cell clicked routine gets called. I would prefer to have the checkbox routine called no matter where I click in the box
Did you try to make the checkbox width the same as the cell layout panel width. See below code:
B4X:
For i = 1 To CheckedColumn.CellsLayouts.Size - 1
        Dim p As B4XView = CheckedColumn.CellsLayouts.Get(i)
        Dim chk As CheckBox
        chk.Initialize("chk")
        p.AddView(chk, 0, 0, p.Width, p.Height)  'make width of chkbox same As Panel width
        Dim B4Xcheck As B4XView=chk
        B4Xcheck.SetColorAndBorder(XUI.Color_Blue,3dip,XUI.Color_Yellow,3dip) 
    Next
As for the other questions, you probably need to show the code for your buttons click and the code for the checkboxes for someone more knowledgeable to answer them and answer the rest of your issues. Normally, Erel prefers one question per thread, so your other questions do not get drowned.
 
Last edited:
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
When I do as you suggested. That seems to handle the clicking around the edges (no matter where I click the checkbox gets checked) BUT now my checkbox again is located on the far left instead of the center of the panel.

If I resize the checkbox to center it. The user can click on the edges (which I think I can handle by getting that click and calling the checkbox routine)
if I make the checkbox the size of the the panel then it is positioned to the far left instead.

I am attaching the program (it is a beat up version of Erel's B4XTable Example - NOTE: A lot of crap in there (I am just trying to figure out how to make it do what I need it to do - just a learning session)

I think I can get the row when the checkbox or button is pressed (where the button is relative to the page added to the top row of the screen).

But how to not have the checkbox or button displayed on the empty rows
 

Attachments

  • B4XTable Example.zip
    64.2 KB · Views: 161
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Well after some hours. Figured out how to do just about everything I needed to do.
how to not have the checkbox or button displayed on the empty rows
1. Can you post the code that allowed you to get rid of the checkboxes and buttons on the empty rows.
2. What is the final code you ended up with in: Sub CheckBox_CheckedChange(Checked As Boolean)
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Not sure if I did this right. But in my UpdateData routine I check the RowID and if the RowID = 0 then I hide the fields otherwise I show the fields

Hopes this helps you.
 

Attachments

  • B4XTable Example.zip
    64.1 KB · Views: 210
Upvote 0
Top