CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

GMan

Well-Known Member
Licensed User
Longtime User
How can i fill in datas from an saved file, i.e. lbl.Text = Text ?
The file is a simple list, line by line
 

GMan

Well-Known Member
Licensed User
Longtime User
Reading the list works already, but "go over the list..." isn't clear to me

THIS don't works and throughs an NullPointerException:
B4X:
For Each Line As String In File.ReadList(RichtigerSDKartenPfad & "/LocoTimer/","LocoList.txt")
        clv3.Add(CreateListItem(Line, clv3.AsView.Width, 50dip),50dip, Line)
    Next

Got it - forgot to initialize the clv3
B4X:
    clv3.Initialize(Me, "clv3")
    Activity.AddView(clv3.AsView, 0, 50%y, 100%x, 50%y)
 For Each Line As String In File.ReadList( RichtigerSDKartenPfad & "/LocoTimer/","LocoList.txt")
        clv3.Add(CreateListItem(Line, clv3.AsView.Width, 50dip),50dip,Line)
   Next
 
Last edited:

GMan

Well-Known Member
Licensed User
Longtime User
So far my LocoTimer works, but only for one Locomotive :-(
How can i generate timers at runtime depending on a runtime given variable ?
As i cant combine variable name to a new variable name (Locotimer (as Timer) & LocoName (as String) to make a new timer (cause the then generated name does not exist as a i.e., LocoTimerBR151_Tick (bulit from the timer LocoTimer and the variable of the checked locomotive,here BR51).

Here is the code i am using (lightly modified with a Total Runtime Label (lbllbl):
B4X:
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.Color = Colors.Black
  
' 1. das Label mit Text
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
    lbl.Text = Text
    lbl.TextSize = 16
    lbl.TextColor = Colors.White
' 2. der Button  
    Dim b As Button
    b.Initialize("button") 'all buttons click events will be handled with Sub Button_Click  
    b.Text = "Info"
' 3. Die Gesamtlaufzeit RuntimeTotal
    Dim RuntimeTotal As Label
    RuntimeTotal.Initialize ("RuntimTotal")
    RuntimeTotal.Text = "00000,00"
    RuntimeTotal.TextSize = 12
    RuntimeTotal.Gravity = Bit.OR (Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL )
    RuntimeTotal.TextColor = Colors.Cyan
' 4. die CheckBox
    Dim chk As CheckBox
    chk.Initialize("chk")
  
    p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
    p.AddView(b, 155dip, 2dip, 60dip, Height - 4dip) 'view #1
    p.AddView(RuntimeTotal,215dip,2dip,60dip, Height - 4dip) 'view2 (eigentlich die 3.)
    p.AddView(chk, 280dip, 2dip, 50dip, Height - 4dip) 'view #3 (vormals die 2.)
  
    Return p
End Sub

Sub chk_CheckedChange(Checked As Boolean)
    Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
  
    'Dim lbllbl As Label
    lbllbl = pnl.GetView(2)
  
    Dim chk As CheckBox
    chk = pnl.GetView(3)
  
    Dim lbllbltimer As Timer
  
    ' Works for a single Timer
    If chk.Checked = True Then
        lbllbltimer.Initialize ("lbllblTimer" ,1000)
        lbllbltimer.Enabled = True
        lbllbl.Text = lblblzeitvalue
    End If
  
    ' Works not
    If chk.Checked = False Then
        lbllbltimer.Enabled = False
        lbllbl.Text = lbllbl.Text
        lblblzeitvalue = 0
    End If
    'Msgbox("Item value: " & clv3.GetValue(index) & CRLF & "Check value: " & chk.Checked, "")
End Sub

Sub lbllbltimer_Tick
    lblblzeitvalue = lblblzeitvalue + 1
    'ToastMessageShow(lblblzeitvalue, False)
    lbllbl.Text = lblblzeitvalue
    lbllbl.Invalidate
      
End Sub

As written: starting ONE timer (the checked one) works, stopping it (by UNchecking) not.

Also it is only 1 timer (as written above)....
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I have been looking (GestureDetector & Gesturs lib)
What is the best way do a drag - drop between 2 CustomListViews?

Thanks
 

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Hi, it's possible to insert the transparency on background of the text, in the CustomListView?
How do you do?
Thanks

 

DonManfred

Expert
Licensed User
Longtime User
Hi, it's possible to insert the transparency on background of the text, in the CustomListView?
How do you do?

What type of Object is that where the Text appears?
I believe it is a label; have you tried to change the Labels color to Transparent?

 

CyclopDroid

Well-Known Member
Licensed User
Longtime User
Nothing. the object when I pass into CustomListView is a Label but not appear trasparent background.


B4X:
SV.AsView.Color=Colors.White
txtRix.color=Colors.Transparent
SV.AddTextItem(txtRix.text,txtPnt)

The txtRix color is white but the background is black. The line of the background image can not be seen.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Hi Erel,

I would like to change the height dynamically when clicking on the panel. Just like the Expandable panels sample but with a Customlistview.

Trying to do this but does not work:

Dim pnl As Panel
pnl = clvDrawer.GetPanel(Index)
Log (pnl.Tag)
pnl.Height=400dip

Any suggestions?
 

bluedude

Well-Known Member
Licensed User
Longtime User
Hi Erel,

I was wondering, is there a way to update a view in a panel inside the Customlistview by using the Tag as update ID? I'm using tag to load my record id's from a REST interface. Sometimes I need to update a listitem with a certain tag value.

For example: I have a list of iBeacon UUID's with proximity in meters. These iBeacons update every 4 secs. and when proximity changes I want to change only that View in the list.

Cheers.
 

bluedude

Well-Known Member
Licensed User
Longtime User
Done these things and added it to the class. Now have a GetPanelByTag method to get to the correct panel.

In combination with websockets it can make a Listview pretty flexible because you can update pieces of info in a list.

Now next thing is that I need itemindex in the designer That way I don't need to guess which index is which view.

I always use layout files for convenience.
 

Silv

Member
Licensed User
Longtime User
Hi erel, is there way to strikethrough with rich string a customlistview item?
Thanks
 

Silv

Member
Licensed User
Longtime User
I found, if somebody need so we need to change type from string to object of second paremeter of CustomListView class right here
B4X:
Public Sub InsertAtTextItem(Index As Int, Text As Object, Value As Object)
 

Levisvv

Member
Licensed User
Longtime User
This Custom Listview is exactly what I was looking for and works great except:
I cannot seem to get it behind any other views?? Any reason why? I have a few cases were I use an overlay label 50% dark when the app is offline, but this Custom Listview is ALWAYS on top of everything and it is always visible, even when I set it's visible value to false.

Anything I might be doing wrong?
 

Levisvv

Member
Licensed User
Longtime User
I added it in Designer and changed it to visible=false and even moved it to the /back/ of all other views. It is still on top of all other views and hidden even when I don't want it to be.
Is there something in your customlistview class library that might be forcing it visible? I have not looked there yet.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…