Android Question customlistview with 3 or 2 button in one row

harry2017

Member
Licensed User
I have been use scrollview before to user 2 button in one row , but I have sugesstion from DonManfred dan Erel to used customlistview

I need example how todo on customlistview...

the exampe Im very apreciated

regard

Harry
 

Attachments

  • 24-11-2017 02.10.jpg
    24-11-2017 02.10.jpg
    74.6 KB · Views: 215

mangojack

Well-Known Member
Licensed User
Longtime User
Firstly download the Lib and example here .. https://www.b4x.com/android/forum/threads/customlistview-a-flexible-list-based-on-scrollview.19567/

In the Designer , edit the "CellItem" layout to how you want each row to appear ... ( delete the example label and checkbox and add another button instead)
* Declare the new Buttons in Globals

Then ...
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    For i = 0 To 10
    clv2.Add(CreateListItem( i, clv2.AsView.Width, 70dip, True), 70dip, $"Item #${i}"$)
    Next  
End Sub

Sub CreateListItem(Text As String, Width As Int, Height As Int, isBold As Boolean) As Panel
    Dim p As Panel
    p.Initialize("")
    Activity.AddView(p, 0, 0, Width, Height)
    p.LoadLayout("CellItem")
    p.RemoveView      
  
    Button1.Text = "Button1 Row" & Text
    Button2.Text = "Button2 Row" & Text  
    Return p
End Sub

Note .. the above is very basic and there is a lot more work to achieve something similar to your image.

But it is a start ;)
 
Last edited:
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
The line in Post#3 should be Ok ??

It would be less painful to download the working example.
 

Attachments

  • CLV Buttons Example.zip
    11.7 KB · Views: 162
Upvote 0

harry2017

Member
Licensed User
thanks mangojack dan Donmanfred for the code and example ..I really really thanks
but I want is I put button1 in designer and every record ,,,button1 otomaticly insert to customlistview row to right 2 button and next another row but still button1 , if record nothing button1 is none ,if record one buton1 is only one ,if record 2 button1 is two ,if records 3 button1 2 button1 in first row and 1 in the next row

regard

harry
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I am sorry .. I do not understand .. Saya tidak mengerti

Can anyone else shed light on harry's intentions ?
 
Upvote 0

harry2017

Member
Licensed User
I am sorry .. I do not understand .. Saya tidak mengerti

Can anyone else shed light on harry's intentions ?
I upload project sample made with scrollview and I want to make with customlistview
 

Attachments

  • sampleaddandminus.zip
    511 KB · Views: 125
  • only1recorddata.zip
    2.4 KB · Views: 153
  • 3recorddata.zip
    2.4 KB · Views: 133
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
thanks mangojack dan Donmanfred for the code and example ..I really really thanks
but I want is I put button1 in designer and every record ,,,button1 otomaticly insert to customlistview row to right 2 button and next another row but still button1 , if record nothing button1 is none ,if record one buton1 is only one ,if record 2 button1 is two ,if records 3 button1 2 button1 in first row and 1 in the next row

regard

harry

What I could understand (I get lots of email requesting some features, in this type of language :) )
1. No record in database = show 1 button
2. One record in database = show 1 button
3. Two records in database = show 2 buttons in a row
4. Three records in database = show 2 buttons in a row and next button in next row.
and so on..

Regards,

Anand
 
Upvote 0

harry2017

Member
Licensed User
What I could understand (I get lots of email requesting some features, in this type of language :) )
1. No record in database = show 1 button
2. One record in database = show 1 button
3. Two records in database = show 2 buttons in a row
4. Three records in database = show 2 buttons in a row and next button in next row.
and so on..

Regards,

Anand

1.no record = no button
2. 1 record = 1 button in row
3. 2 record = 2 button in row
4. 3 record = 2 button in row and 1 in next row
and so on


regard harry
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
I found it easier to get your needed result with a Scrollview .

I have attached a simple example which will demonstrate the basics of what what you need to do. There is certainly refinements to be be made.

I have also made several comments regarding Declaring / Initialising your SQL object and db files etc in the Starter service.

Start a new thread if you have any further questions.
 

Attachments

  • ScrollView Example1.zip
    26.2 KB · Views: 149
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
if you still need to use CLV which i think would be easier than ScrollView then you could adapt this sample code. ( is in B4J )
A better / simpler approach .. ;) I was trying to reposition the single layout within the clv row/panel and finally gave up.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
This was bugging me and couldn't let it go.

Based on @XbNnX_507 B4J idea /example ... just including possible way of updating items with db data as you go. Mainly for @harry2017 's benefit .

On to other things :)
 

Attachments

  • CLV Example 2.zip
    26.8 KB · Views: 181
Upvote 0

harry2017

Member
Licensed User
wow ... thanks mangojack ...I will try the second example ...I ready finish with the first example ...but will try the second one

regard

harry
 
Upvote 0

harry2017

Member
Licensed User
This was bugging me and couldn't let it go.

Based on @XbNnX_507 B4J idea /example ... just including possible way of updating items with db data as you go. Mainly for @harry2017 's benefit .

On to other things :)
I found it easier to get your needed result with a Scrollview .

I have attached a simple example which will demonstrate the basics of what what you need to do. There is certainly refinements to be be made.

I have also made several comments regarding Declaring / Initialising your SQL object and db files etc in the Starter service.

Start a new thread if you have any further questions.

hi mangojack ..I try used your example then I add one button to refresh data but the panel always add new panel ,after I delete the row with ( SV1.panel removeview),the data alway add new panel ( the first record before is blank( empty) panel nothing show.
could you try to refresh data ..

regard

harry
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Please start a new thread explaining your problem .. maybe with a sample project.

In hindsight it would be simpler to use the CustomListView option
 
Upvote 0
Top