Android Question [SOLVED] CustomListView, not working correctly on EMUI 10

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

Attached are screen shoot and sample project of CustomListView.

From the screen shoot, the first & last item of CustomListView didn't display correctly.
Only after, Activity Resume triggers, CustomListView display all items correctly.

On Android 9 & below, no problem like this.

Any idea how to fix this?
 

Attachments

  • Screenshot.jpg
    Screenshot.jpg
    159.4 KB · Views: 156
  • Clv.zip
    11.4 KB · Views: 145

incendio

Well-Known Member
Licensed User
Longtime User
That's weird.

What's your phone? My is Honor 10.

Have you tried to change display size & text size via the OS.

On my phone, only if display size set to huge & text size set to normal, it will display correctly.
Other than that size, it will display incorrectly.
 
Last edited:
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
View attachment 96319 Strangely the text "Info" is lost. Without a real reason... try to add a Sleep(0 [or more, <= 30]) to the bottom of your CreateListItem (before "Return p", of course)
Add Sleep solved the problem with this sample, but, when I tried the same method on the real project, Sleep didn't solve the problem.

There is another strange thing on real project, I add this code
B4X:
Sub Delay
    LogColor(1,Colors.Yellow)
    Sleep(5000000)
End Sub

Sub CreateListItem(Menu As String, Dscp As String,Height As Int) As Panel
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, 100%x, Height)
    p.LoadLayout("lyMn")
    p.Color = Colors.RGB(48,48,48)
    LblMn.Text = Menu
    LblMn.TextColor = Colors.RGB(250,235,215)
    LblMnDscp.Text = Dscp
    Delay
    Return p
End Sub

Sleep(5000000) didn't delay app as expected, app just ran as if there no delay at all.
 
Upvote 0

Cadenzo

Active Member
Licensed User
Longtime User
Sleep(5000000) didn't delay app as expected
Your Sleep(5000000) works like a return (and comes back in 5000 seconds) and your "Delay" will not wait. You need to put the Sleep directly in the function where you want to wait or work with ResumleSub.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
That's the problem.

The original clv. Add procedure will raised an error if CreateListItem returned as a ResumebleSub.

Will try to modify that procedure after get my hands on the computer again.
 
Upvote 0

incendio

Well-Known Member
Licensed User
Longtime User
I changed the code to this
B4X:
Sub CreateListItem(Menu As String, Dscp As String) As Panel
    Dim p As Panel
    p.Initialize("")
    p.LoadLayout("lyMn")
    p.SetLayout(0, 0, 100%x, LblMn.Height*1.65)
    p.Color = Colors.RGB(48,48,48)
    LblMn.Text = Menu
    LblMn.TextColor = Colors.RGB(250,235,215)
    LblMnDscp.Text = Dscp
    Return p
End Sub
Removed parameter height, and calculated panel height based on label height, and it solved the problem.

Weird, but worked.
 
Upvote 0
Top