Android Question Panels Corrupted/Moved When Label Text Within Them Updated

Big Dave

Member
Licensed User
Longtime User
I am writing a program that consists of panels 5 across and 5 down with a label in each panel to give the effect of a border. Connecting each panel is a link consisting of a small panel within a panel, again to represent a border on the link. Each square is initially filled with a letter of the alphabet which is then randomly swapped from one square to another. The problem occurs when the letters are swapped with the effect that the links are somehow either moved, slightly covered up or in some way corrupted. All the panels and links are created within the program. I am at a loss as to where/what the problem may be.

Code to create squares:

' Column 1 Squares
For x = 0 To 4
Dim p As Panel
' Add panel
p.Initialize("pnlSquare")
p.Background = cdPanel
p.Tag = intSquareNo
Activity.AddView(p, 263, 6 + (x * 100), 90dip, 90dip)
' Add letter label as view=0
lblLetter.Initialize("lblLetter")
lblLetter.Background = cdLetter
lblLetter.TextColor = Colors.Black
lblLetter.Text = strLetters.CharAt(intSquareNo)
lblLetter.TextSize = 60
lblLetter.Typeface = Main.ErasBoldFont
lblLetter.Gravity = Gravity.CENTER
p.AddView(lblLetter, 4, 4, 82, 82)
pnlSquare(intSquareNo) = p
intSquareNo = intSquareNo + 1
Next

Code to create links between column 1 and column 2

' Column 1-2 Links
For x = 0 To 8
Dim p As Panel
' Add panel
p.Initialize("pnlLink")
p.Background = cdLink
p.Tag = intLinkNo
Activity.AddView(p, 349, 68 + (x * 50), 24dip, 16dip)
' Add Colour Panel As View 0
pnlColour.Initialize("pnlColour")
pnlColour.Background = cdLinkGold
pnlColour.Tag = intLinkNo
p.AddView(pnlColour, 4, 4, 20, 8)
pnlLink(intLinkNo) = p
intLinkNo = intLinkNo + 1
Next

Code in timer to randomise letters:

Sub Timer1_Tick
intRndNo1 = 0
intRndNo2 = 0

DoWhileintRndNo1 = intRndNo2
intRndNo1 = Rnd(0,25)
intRndNo2 = Rnd(0,25)
Loop

lblLetter = pnlSquare(intRndNo1).GetView(0)
strLetter1= lblLetter.Text
Log (strLetter1)
lblLetter = pnlSquare(intRndNo2).GetView(0)
strLetter2 = lblLetter.Text
Log (strLetter2)
Log ("===")
lblLetter.Text = strLetter1
lblLetter = pnlSquare(intRndNo1).GetView(0)
lblLetter.Text = strLetter2

End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Please use Code-Tag around your code ([code ]your code[ /code] (without the spaces))

B4X:
your code
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
DonManfred.. Thanks for the tip. Its my first post on here and still learning the ropes.

NJDude.. I have applied the changes as you suggest but unfortunately the problem still exists. When the links are created on the screen they are exactly as I want them. When I move the letters around the squares is when the links become different. Its like they have moved slightly. What is also confusing is that it only affects the links left and right. The links that join squares top and bottom are not affected.??
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
DomManfred.. Tried to upload the zip but it is too large to post on here. Happy to get it to you some other way if you want.

Thanks for your help.
 
Upvote 0

Big Dave

Member
Licensed User
Longtime User
Just removed an mp3 file which has made it somewhat smaller!!!
 

Attachments

  • Kon11Error.zip
    121 KB · Views: 225
Upvote 0
Top