Android Question CustomListView EditText.text only the last one works of the list of items

Daniel-White

Active Member
Licensed User
Longtime User
Hi, folks.

- Summary: The idea is when the user uses the edittext1 in item #1 obtain the ingressed value and show in a msgbox take a look "Sub EditText1_EnterPressed" . the same when the user put something in edittext1 of item #2 and so on.

- Actual and bad Behavior: Pressing the edittext1 in Item #1 it showing the value the content of the last Item, in this case, Item #3, the same if I put some text in item #2 the msgboxs all the time showing the value of the last edittext1 in item #3

- Expected Behavior: Show in the msgbox the actual text inside of edittext1 of item #1, the same if I am working in edittext1 of item #2 show the correct value.



upload_2017-10-4_11-3-54.png






B4X:
Sub Globals
    Private clv1 As CustomListView
    Private lblTitle As Label
    Private pnlTitle As Panel
    Private ExpandedHeight As Int = 240dip
    Private CollapsedHeight As Int = 60dip
    Private pnlExpanded As Panel
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    For i = 1 To 3
        clv1.Add(CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), "Item #" & i), CollapsedHeight, "")
    Next
End Sub

Sub CreateItem(clr As Int, Title As String) As Panel
    Dim p As Panel
    p.Initialize("")
    Activity.AddView(p, 0, 0, 100%x, ExpandedHeight)
    p.LoadLayout("Item")   
    p.RemoveView 'remove from parent
    lblTitle.Text = Title
    pnlTitle.Color = clr
    pnlExpanded.Color = ShadeColor(clr)
    p.Tag = False 'collapsed
    Return p
End Sub

Sub ShadeColor(clr As Int) As Int
    Dim argb() As Int = GetARGB(clr)
    Dim factor As Float = 0.75
    Return Colors.RGB(argb(1) * factor, argb(2) * factor, argb(3) * factor)
End Sub

Sub GetARGB(Color As Int) As Int()
    Private res(4) As Int
    res(0) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff000000), 24)
    res(1) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff0000), 16)
    res(2) = Bit.UnsignedShiftRight(Bit.And(Color, 0xff00), 8)
    res(3) = Bit.And(Color, 0xff)
    Return res
End Sub

Sub ExpandItem (index As Int)
    clv1.ResizeItem(index, ExpandedHeight)
    clv1.GetPanel(index).Tag = True
    AnimatedArrow(index, 0, 180)
End Sub

Sub AnimatedArrow(index As Int, From As Int, ToDegree As Int)
    Dim An As AnimationPlus
    pnlTitle = clv1.GetPanel(index).GetView(0) 'pnlTitle is the first item
    Dim iv As ImageView = pnlTitle.GetView(1) 'ImageView1 is the second item
    An.InitializeRotateCenter("", From , ToDegree, iv)
    An.Duration = clv1.AnimationDuration
    An.RepeatCount = 0
    An.PersistAfter = True
    An.Start(iv)
End Sub

Sub CollapseItem(index As Int)
    clv1.ResizeItem(index, CollapsedHeight)
    clv1.GetPanel(index).Tag = False
    AnimatedArrow(index, 180, 0)
End Sub

Sub clv1_ItemClick (Index As Int, Value As Object)
    Dim p As Panel = clv1.GetPanel(Index)
    If p.Tag = True Then
        CollapseItem(Index)
    Else
        ExpandItem(Index)
    End If
End Sub


Sub EditText1_EnterPressed
    Msgbox(EditText1.Text,"Show me the vaule in edittext.text")
End Sub


Thanks guys
 

Daniel-White

Active Member
Licensed User
Longtime User
You should post a small project instead of code.
I´m not interested to generate a new project to include your code just to test your issue.

File-Export as zip your project and upload it. It will be easier for us to follow/help

Hi, Don, here is the Zip exported, thanks for taking a look into.
 

Attachments

  • CODEzipped.zip
    12.9 KB · Views: 306
Upvote 0
Top