Android Question visual issue in a customlistview after opening the virtual keyboard

leitor79

Active Member
Licensed User
Longtime User
Hi,

I have a customlistview that I load item by item from a template layout (.bal file), with some views (one panel, 2 autotextsizelabel, 2 imageviews) I set.

After a long-pressing a row's view, an inputdialog (or a betterdialog) is shown. Once the keyboard is shown (after touching the inputdialog text box or automatically in the betterdialog) a "grey hole" appears over the customlistview that stays after the dialog is closed.

This is the row layout; the positions and sizes are set by script.

2017-04-17 21_54_50.png



this is how the customlistview is shown after loading
clv0.jpeg

after the keyboards opens, the grey hole appears
clv1.jpeg

this is how it looks when the dialog is closed. note that the edges of the hole doesn't match te edges of the views (at least not the left one)
clv2.jpeg

I've tried, for example, manually refreshin a panel after the dialog closes. clv1.getpanel(1).invalidate; it does nothing.

Any ideas where could I start looking?

Thank you very much!
 

leitor79

Active Member
Licensed User
Longtime User
Hi Erel, thank you very much for your answer.

I've tried the callsubdelayed solution and it didn't work. I've moved the dialog logic to another sub and call it with callsubdelayed, but the same happes. I've tried moving the input-sub to a service, but I get an exception: (BadTokenException) android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

So, maybe I'm doing something wrong or there is a particular issue with the things I use; I'm pasting the code behind.

But, in order to keep learning, I'd also like to ask:

- Why does this (could) happen? (I think that if you suggest some solution is because you have some ideas)

- Why using a regular panel would be a better solution?

- I'm not sure I see how to implement the panel solution. Shall I add, by code, a panel all over the other views, with a thextbox and 2 buttons in the center?

Thank you very much for your awesome support!


'osender is a parameter with the sender object that fired the event (a button)
Sub InputValorAddORemove(sMensaje As String, oSender As Object) As Int

Dim BD As BetterDialogs
Dim DR As Int
Dim IP As BD_InputBoxParams

Try

IP.Initialize
IP.Question = "Value to add2"
IP.QuestionTextSize = 18
IP.SpaceBetween = 4dip
IP.InputTextSize = 24
IP.InputType = IP.INPUT_TYPE_NUMBERS
IP.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
IP.ValidationCallback = "Input_Validation"
IP.WithSuggestions = True

DR = BD.InputBox("Add a Value2", IP, "Add", "Cancel", "", Null)
Log("DR=" & DR)
If DR = DialogResponse.POSITIVE Then
CallSubDelayed3(Me, "ModificarValor", oSender, IP.Answer)
End If
Catch
LogColor(LastException, Colors.Yellow)
End Try

End Sub

Sub Input_Validation(Answer As String, CompactAnswer As String) As String
If CompactAnswer = "" Then
Return "Cannot be empty"
Else
Return ""
End If
End Sub
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried moving the input-sub to a service, but I get an exception: (BadTokenException) android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
You cannot show a dialog from a service.

Modal dialogs interfere with the internal message queue. My guess is that it is related to this visual issue. Try it with a regular panel. Just show it over the other views when needed.
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hello Erel,

I know this post is old but the problem has returned (I've not been using this for a while).

I've put the customlistview inside a panel inside an AHViewPager/AHPageContainer. When I change the page and then go back (using the DSTabLayout) the the "hole" appears again. No keyboard nor dialog or non dialogs are shown in the process.

I'm using v7.3, customlistview 1.76, AHViewPager 3.0.

Regards!
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi! Thank you for your answer!

Is a drawable object the one I load, for example, with
B4X:
xml.GetDrawable("ic_insert_chart_black_24dp")
? In case "yes", I will check for that.
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Ok, I'll check that later, I'll open another post because I have question regarding what I understand the xml.GetDrawable is (was?) needed for.

Meanwhile, I've checked my drawables and I'm not reusing them.

I think It would be useful but just in case; I've tried refreshing the CLV in the PageChanged event, without results:

B4X:
    cv1.AsView.Invalidate
    cv1.sv.Invalidate
    Dim i As Int
    Dim j As Int
    j = cv1.GetSize-1
    For i=0 To j
        cv1.GetPanel(i).Invalidate
    Next
    Sleep(0)

Regards,
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Hi Erel, thank you for your answer.

I've removed all GerDrawables and the issue persists.

I appreciate your help!
 

Attachments

  • customlistviewerrordemo.zip
    17.6 KB · Views: 117
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I haven't checked everything but this is exactly what you should avoid doing:
B4X:
  Dim dPanel As ColorDrawable
   
   Dim P As Panel
   Dim T As Tipo
   Dim c As Canvas
   
   Try
   
     cv1.Clear
   
     For Each item In Lista
       t = item
       Dim iv As ivList
       P.Initialize(T.id)
       P.LoadLayout("layrow")
       lblNombre.Text = T.Nombre
       lblValor.Gravity = Bit.Or(Gravity.CENTER_HORIZONTAL, Gravity.CENTER_VERTICAL)

       dPanel.Initialize(T.ColorFondo, 2)
       P.Background = dPanel
     
       lblNombre.BackGround = dPanel
       lblValor.BackGround = dPanel
       'pnlMain.Background = dPanel
       imgAdd.Background = dPanel
       imgRemove.Background = dPanel
You shouldn't reuse the same drawable object. Create a sub that creates a ColorDrawable and use it:
B4X:
Sub CreateColorDrawable As ColorDrawable
 Dim dPanel As ColorDrawable
 dPanel.Initialize(...)
 Return dPanel
End Sub
 
Upvote 0

leitor79

Active Member
Licensed User
Longtime User
Problem solved Erel, it was what you've said, thank you very much. You've said "reusing drawables" and I thought about the png's, not the object type. My mistake.

Thank you very much, again.
 
Upvote 0
Top