Android Question Problem with invalidate and a panel

nchazarra

Member
Licensed User
Longtime User
Hi to everybody,

I'm trying to create a jupiter moons movement calculator, but when I try to draw and delete the drawing on the panel, everything stays there. Can anyone see my error?

Thanks in advance

B4X:
Sub dibujaposicion
Dim sa As List
sa.Initialize
sa.AddAll(posicionlunas)
canvas2.DrawCircle(50%x, 50%y, 20dip, Colors.Red, True, 10dip)
canvas2.DrawCircle((sa.get(0)*2%x)+50%x,(sa.get(1)*2%y)+50%y, 5dip, Colors.blue, True, 10dip)
canvas2.DrawCircle((sa.get(2)*2%x)+50%x,(sa.get(3)*2%y)+50%y, 5dip, Colors.green, True, 10dip)
canvas2.DrawCircle((sa.get(4)*2%x)+50%x,(sa.get(5)*2%y)+50%y, 5dip, Colors.magenta, True, 10dip)
canvas2.DrawCircle((sa.get(6)*2%x)+50%x,(sa.get(7)*2%y)+50%y, 5dip, Colors.white, True, 10dip)


End Sub
Sub Button3_Click
'Dim sa As List
'sa.Initialize
    'sa.AddAll(posicionlunas)
   
    'Dim canvas1 As Canvas

panel1.visible=False
panel2.Visible=True
canvas2.Initialize(panelmoon)
dibujaposicion

    'canvas1.DrawCircle(50%x, 50%y, 20dip, Colors.Red, True, 10dip)
'canvas1.DrawCircle((sa.get(0)*2%x)+50%x,(sa.get(1)*2%y)+50%y, 5dip, Colors.blue, True, 10dip)
'canvas1.DrawCircle((sa.get(2)*2%x)+50%x,(sa.get(3)*2%y)+50%y, 5dip, Colors.green, True, 10dip)
'canvas1.DrawCircle((sa.get(4)*2%x)+50%x,(sa.get(5)*2%y)+50%y, 5dip, Colors.magenta, True, 10dip)
'canvas1.DrawCircle((sa.get(6)*2%x)+50%x,(sa.get(7)*2%y)+50%y, 5dip, Colors.white, True, 10dip)
End Sub

Sub adelantel_Click
panelmoon.invalidate
    JDN=JDN+0.1
    dibujaposicion
    End Sub
Sub atrasl_Click
panelmoon.Invalidate
    JDN=JDN-0.1
    dibujaposicion
   
End Sub
 

Attachments

  • activity.jpg
    71 KB · Views: 158

nchazarra

Member
Licensed User
Longtime User
Thanks Klaus, but I think I've tried almost everything, but it doesn't works. This is the new code, but still not working:

B4X:
Sub Activity_Create(FirstTime As Boolean)
        Dim sa As List
   
    rectcorta.Initialize(0,100%x,100%y,0)
    Activity.LoadLayout("main")
    panel1.LoadLayout("prueba")
    panel2.LoadLayout("lunas")
    panel2.Visible=False
    panel1.Height=100%y
    panel1.Width=100%x
    panel1.Visible=True
   
    juliano
    JDN=juliano
    'JDN=2448972.50068
    pases
    posicionjupiter
    sa.Initialize
    sa.AddAll(posicionlunas)
Label4.Text="Pase 1"
Label5.Text="Pase 2"
Label6.Text="Pase 3"
Label7.Text="Calculador de tránsitos de la GMR"
Label7.TextSize=40
Label7.TextColor=Colors.Red
Label7.Gravity=Gravity.CENTER
adelantel.Text="+10 min"
atrasl.Text="-10 min"
button3.Text="Moons"
'canvas2.Initialize(Activity)
canvas2.Initialize(panelmoon)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    JDN=JDN+1
    pases
End Sub

Sub Button2_Click
    JDN=JDN-1
    pases
End Sub
Sub dibujaposicion
Dim sa As List
sa.Initialize
sa.AddAll(posicionlunas)
canvas2.DrawCircle(50%x, 50%y, 20dip, Colors.Red, True, 10dip)
canvas2.DrawCircle((sa.get(0)*2%x)+50%x,(sa.get(1)*2%y)+50%y, 5dip, Colors.blue, True, 10dip)
canvas2.DrawCircle((sa.get(2)*2%x)+50%x,(sa.get(3)*2%y)+50%y, 5dip, Colors.green, True, 10dip)
canvas2.DrawCircle((sa.get(4)*2%x)+50%x,(sa.get(5)*2%y)+50%y, 5dip, Colors.magenta, True, 10dip)
canvas2.DrawCircle((sa.get(6)*2%x)+50%x,(sa.get(7)*2%y)+50%y, 5dip, Colors.white, True, 10dip)
panelmoon.invalidate

End Sub
Sub Button3_Click

panel1.visible=False
panel2.Visible=True

dibujaposicion

   
End Sub

Sub adelantel_Click
    JDN=JDN+0.1
    dibujaposicion
    End Sub
Sub atrasl_Click
    JDN=JDN-0.1
    dibujaposicion
   
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…