CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

peacemaker

Expert
Licensed User
Longtime User
Where is the code to add the CustomListView?
(lbl can be a name for a label. edt should be better ;))

CustomListView is added just by the Designer (Private cv As CustomListView) and all other for the dynamical use is already shown in the code above.
Other work is by checking the checkboxes state:

B4X:
Dim L As List
L.Initialize
For i = 0 To cv.GetSize - 1
    Dim pnl As Panel = cv.GetPanel(i)
    Dim chk As CheckBox = pnl.GetView(0)
    If chk.Checked Then
        L.Add(i)
    End If
Next
 

LucaMs

Expert
Licensed User
Longtime User
Perfect, now I have the same problem in my project.

If the CustomListView is created inside the Activity_Create, there is no problems with GetItemFromView called in the TextChanged event of an EditText added to a custom item.
If it is created after the Activity_Create is completed (pressing a button, for example) the TextChanged event will raise during the creation of the CustomListView and GetItemFromView gets a null parent.

[My CLV is not added using the Designer]
 

LucaMs

Expert
Licensed User
Longtime User
Perfect, now I have the same problem in my project.

If the CustomListView is created inside the Activity_Create, there is no problems with GetItemFromView called in the TextChanged event of an EditText added to a custom item.
If it is created after the Activity_Create is completed (pressing a button, for example) the TextChanged event will raise during the creation of the CustomListView and GetItemFromView gets a null parent.

[My CLV is not added using the Designer]

[solved]
Setting the properties of the EditText after the addition of the "item panel" to the CLV, I get no errors.
 

saeed10051

Active Member
Licensed User
Longtime User
My mistake. I forgot to mention that you need the latest Reflection library.
could you please give me a link to the documentation realated to your list class. Actually I am looking for a list view which can hold name and small picture of the person. something similar to contacts list
Regards
Saeed
 

xor83

Member
Licensed User
Longtime User
Can I set "SetElevation" to each list item? Can anyone share some idea to do that? I tried adding SetElevation to panel but did not worked. Any help?
 

ronovar

Active Member
Licensed User
Longtime User
How can i update items in panel?

For example: i have 300 items in clvMaster list and when apk start it fills 300 items in clvMaster using:

B4X:
clvMaster.InsertAt(ScrolledChannel, CreateChannelListMaster(ScrolledChannel, clvMasterCh.AsView.Width, 167dip, Channels(ScrolledChannel,3), Channels(ScrolledChannel,2), EPGs(ScrolledChannel,0), EPGs(ScrolledChannel,1), EPGs(ScrolledChannel,2), EPGs(ScrolledChannel,3)), 167dip, ScrolledChannel)

That works great...i have the following labels in each panel:

B4X:
'UPDATE - EPG
lblEPGName.Text  = EPGs(ScrolledChannel,0)
lblEPGStart.Text = EPGs(ScrolledChannel,1).SubString2(11, 16)
lblEPGStop.Text  = EPGs(ScrolledChannel,2).SubString2(11, 16)
lblEPGDesc.Text  = EPGs(ScrolledChannel,3)

I have tried using removeitemat and insertitem at but i have duplicate panels, and would like to avoid this...can be added in this excellent class function:

B4X:
Sub UpdateItemsAtPanel(Index As Int, Pnl As Panel, ItemHeight As Int, Value As Object, lblEPGName, lblEPGStart, lblEPGStop, lblEPGDesc As String)
   'UPDATE - EPG
   panel(index).lblEPGName.Text  = lblEPGName
   panel(index).lblEPGStart.Text   = lblEPGStart
   panel(index).lblEPGStop.Text    = lblEPGStart
   panel(index).lblEPGDesc.Text    = lblEPGDesc
End Sub

So the idea is to not remove existing panels in list witch is generated at apk start, only to update labels in existing panels at index....can erel or someone posto here code how to do that with this excellent class?
 

jtare

Active Member
Licensed User
Longtime User
which is the right way to set the item height?
I tried this:
change from original 100dip item height to 200dip itemheight when the user click the item
but I get an error

B4X:
Sub clv2_ItemClick(Index As Int, Value As Object)
    Dim pnlnew As Panel
    Dim newvalue As Object
    newvalue = Value
    pnlnew= clv2.GetPanel(Index)
    clv2.RemoveAt(Index)
    clv2.InsertAt(Index,pnlnew,200dip,newvalue)
    Log(Index & " = " & Value)
End Sub

then I tried this and it worked:

B4X:
Sub clv2_ItemClick(Index As Int, Value As Object)
    Dim newvalue As Object
    newvalue = Value
    pnlnew= clv2.GetPanel(Index)
    clv2.RemoveAt(Index)
    clv2.InsertAt(Index,CreateListItem($"Item #${Index+1}"$, clv2.AsView.Width, 100dip),200dip,newvalue)
    Log(Index & " = " & Value)
End Sub

Is there a way to only change the item height without deleting and adding the same item?
 

PABLO2013

Well-Known Member
Licensed User
Longtime User
regards
can you help me
I wanted to know how they could correct this mistake, what I want is to know the panel that contains the view and modify the contents of the text view that the same panel , thanks
 

Attachments

  • sb1.PNG
    sb1.PNG
    5.3 KB · Views: 260
  • sb2.PNG
    sb2.PNG
    53.1 KB · Views: 251

mtselection

Member
Licensed User
Longtime User
Hi,

I can work with array of clv?
When I try to add a panel in the CLV(2) I have the Sub Asview error:
java.lang.NullPointerException: Attempt to read from field 'int android.view.ViewGroup$LayoutParams.width' on a null object reference

I can know the CLV panel position with the method javaobject?
similar to jo.RunMethod("getFirstVisiblePosition", Null) for listview.

thanks
 

rscheel

Well-Known Member
Licensed User
Longtime User
Consultation CustomListView and I scrollview, it is that when the screen is not broken can use the scroll of CustomListView of scrollview only is the activity, which is not error, any idea.
 
Status
Not open for further replies.
Top