Android Question CustomListView reappears

mr23

Active Member
Licensed User
Longtime User
I just added my first usage of CLV.
It functions as expected initially, after an item is selected, and the _Click is called, I clear/disable/sendtoback as shown below, but the CLV shortly reappears with a green highlight on the selected item. I tried using a CallSubDelayed to delay the clear/disable/sendtoback, but it didn't help. Do I need to patch in a wait?

It is under the other controls on the main view. If I poke at it, it flashes and eventually disappears. If instead of using a quick press to select an item, I use a long press, the menu still reappears, but without the green highlight on the pressed item.

Seems like there are queued messages/actions that it receives after my CallSubDelayed actions.

B4X:
Sub Globals
    Dim clv1 As CustomListView ' for menus

Sub Activity_Create(FirstTime As Boolean)
    clv1.Initialize(Me,"clv1")
    Activity.AddView(clv1.AsView, 25%x, 25%y, 50%x, 50%y)
    clv1Hide

Sub clv1Hide
    clv1.AsView.Color = 0
    clv1.AsView.Enabled = False
    clv1.AsView.SendToBack
    clv1.Clear
End Sub

Sub mnuBtn_Click  ' GUI button handler
    clv1.Clear
    clv1.AddTextItem("Do A",0)
    clv1.AddTextItem("Do B",1)
    clv1.AddTextItem("Do C",2)
    clv1.AddTextItem("Do D",3)
    clv1.AsView.Color = Colors.Gray
    clv1.AsView.Enabled = True
    clv1.AsView.BringToFront
End Sub

Sub clv1_ItemClick (Index As Int, Value As Object)
    ' Try doing action delayed
    CallSubDelayed2(Me,"MenuItemAction",Index)
End Sub

Sub MenuItemAction(Index As Int)
    Select Index
        Case 0
            DoA
        Case 1
            DoB
        Case 2
            DoC
        Case 3
            DoD
    End Select
    ' Try delaying the clear/disable/sendtoback
    CallSubDelayed(Me,"clv1Hide")
End Sub
 
Last edited:

mr23

Active Member
Licensed User
Longtime User
Yes, here it is. The CLV was added into a modified version of the Bluetooth example. I stripped out all non-essentials for this CLV issue, and it still does it. You may have to pull up the menu and hit "Do X" more than one time to get a 'sendtoback' with green highlight, but it always leaves the CLV visible. That is not desired either.

To pull up the menu, hit the lower button, "Make device discoverable". Then choose one of 4. Only the 4th (Do D) takes a real action.

Files:
Bluetooth*.zip: the b4a example stripped.
libsCLV.zip: a CLV library built from the CLV example
CustomListView.zip: the downloaded CLV example, used to create the library.
 

Attachments

  • BluetoothEx_strippedDownForMenuIssue.zip
    9 KB · Views: 156
  • libsCLV.zip
    6 KB · Views: 157
  • CustomListView.zip
    9.6 KB · Views: 175
Upvote 0

mr23

Active Member
Licensed User
Longtime User
Odd. I see Green as the selection color.
It went away after a reboot, for a couple of retests. Then it came back.
After I testeda bit more, it appears to reproduce you need a 'longer than instantaneous' operation to be performed by the menu action.
For example, starting a service.
Then all the menu actions regardless of time to execute cause it to reproduce.
I'll see if I can make a better test package for you, unless you can whip in 'some operation' into the example I provided already.
 
Upvote 0
Top