Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
cc.Initialize(Me, "cc")
Activity.LoadLayout("WandM")
Activity.AddView(cc.AsView, 60%x,8%y, 40%x,80%y)
....
....
...
End Sub
Sub Button7_Click
For i = 1 To 10
cc.Add(CreateListItem("t"& i & ".png",tshirtprices(i)), 30%y, "t"& i & ".png")
Next
End Sub
Sub CreateListItem(picture As String, price As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.LightGray
Dim imgv As ImageView
imgv.Initialize("img")
imgv.Gravity = Gravity.FILL
Dim imgv2 As ImageView
imgv2.Initialize("img2")
imgv2.Gravity = Gravity.FILL
imgv2.Bitmap = a
imgv.Bitmap = LoadBitmapSample(File.DirAssets,picture,40%x,40%y)
Dim lbl As Label
lbl.Initialize("lbl")
lbl.Gravity = Gravity.CENTER
lbl.TextColor = Colors.Black
lbl.TextSize = 10dip
lbl.Text = "$"& price
p.AddView(imgv ,-12%x, -15%y , 60%x, 70%y) 'view #2
p.AddView(imgv2 ,-12%x, -15%y , 60%x, 70%y) 'view #2
p.AddView(lbl ,-1%x, 3%y , 40%x, 30%y)
Return p
End Sub
Sub cc_ItemClick(Index As Int, Value As Object)
Dim str As String
vavl = Value
Dim dd As Int
str = File.ReadString(File.DirInternal,"Items.txt")
If str.Contains(vavl) = False Then
dd = vavl.SubString2(1,vavl.IndexOf("."))
If Home.money > tshirtprices(dd) Then
Dim result As Int
result = Msgbox2("Confirm Purchase", "Are you sure you want to Purchase this item","Purchase","Cancel",Null,LoadBitmap(File.DirAssets,"shoppingcart.png"))
If result = DialogResponse.POSITIVE Then
Home.money = Home.money - tshirtprices(dd)
File.WriteString(File.DirInternal,"money.txt", Home.money)
File.WriteString(File.DirInternal,"Item.txt",str & " " & Value)
File.WriteString(File.DirInternal,"tshirt.txt",Value)
End If
Else
beep.beep
End If
Else
File.WriteString(File.DirInternal,"tshirt.txt",Value)
'File.WriteString(File.DirInternal,"shoes.txt","hobo_shoes.png")
End If
End Sub