dear forum I have a problem here
the case is first load scrollview panel its no problem but after I want to refresh activity to get new data or reload scrollview panel place alway go to the next panel and after I use remove view , panel that I removeview blank and new data is on the next panel.
alway like that ,but if the first load scrollview panel its ok
the case is first load scrollview panel its no problem but after I want to refresh activity to get new data or reload scrollview panel place alway go to the next panel and after I use remove view , panel that I removeview blank and new data is on the next panel.
alway like that ,but if the first load scrollview panel its ok
B4X:
Private SV1 As ScrollView
Private numItems As Int
Private posTop As Int
Private lblDescription As Label
Private bmp As Bitmap
Private ImageView1 As ImageView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1") 'load the layout file
bmp.Initialize(File.DirAssets,"smiley.png")
'### You should really be Declaring and initializing your sql object in the starter service .. see comments in service
'##### You can call the SQL object now with ...... Starter.SQL1
'##### Get Data from DB and update views with the relevant data ...
' listtombol = DBUTILS.ExecuteMemoryTable(Starter.SQL1, "SELECT kdobat, nmobat, satuan,harga,nmkategori,foto FROM tb_obat", Null,0)
list
End Sub
Sub list
Dim nCount As Int
nCount = SV1.panel.NumberOfViews
'For i = 0 To nCount - 1
For i = nCount - 1 To 0 Step -1
SV1.Panel.RemoveViewAt(i)
Next
For i = 1 To 4
numItems = numItems+1
Dim p As Panel
p.Initialize("")
p.LoadLayout("RowItem")
lblDescription.Text = $"description ${numItems}"$ 'ie description of db item
ImageView1.Bitmap = bmp 'and the item image
'Add a new Item Layout to the Scrollview
If numItems Mod 2 <> 0 Then 'if Number of loaded items is uneven (1 , 3, 5 ) load at Left Position & current posTop setting
SV1.Panel.AddView(p, 5dip, posTop + 5dip , 160dip, 180dip)
Else 'if Number of loaded items is even (2 , 4, 6 ) load at Right Position & current posTop setting
SV1.Panel.AddView(p, 180dip, posTop + 5dip, 160dip, 180dip)
posTop = posTop + 210dip '@@ then increase posTop Setting
End If
Next
SV1.Panel.Height = (Ceil(numItems / 2)) * 215dip 'Set the inner panel height according to the number of Loaded Items
End Sub
Sub lblMinus_Click
'Get the parent panel of the clicked label
Dim lbl As Label = Sender
Dim p As Panel = lbl.Parent
Dim l As Label = p.GetView(6) 'get the panel view at the given index .. Refer to the Layout View Tree Tab (in Designer) for index order !
If l.Text > 1 Then l.Text = NumberFormat2( l.Text - 1, 0, 0, 0,False)
End Sub
Sub lblAdd_Click
'Get the parent panel of the clicked label
Dim lbl As Label = Sender
Dim p As Panel = lbl.Parent
Dim l As Label = p.GetView(6) 'get the panel view at the given index .. Refer to the Layout View Tree Tab (in Designer) for index order !
l.Text = NumberFormat2( l.Text + 1, 0, 0, 0,False)
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
list
End Sub