I created a ScrollViewer and added some pictures.
Now I need to get the click event of each image.
Example when I click on each image to show a different message.
How to do this without having to create a click event for each image?
Below the code
---
Thanks for any help
Now I need to get the click event of each image.
Example when I click on each image to show a different message.
How to do this without having to create a click event for each image?
Below the code
B4X:
----
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("frmPrdCatFor")
'Using Database
If FirstTime Then
SQL1.Initialize(mDBFileDir, mDBFileName, True)
End If
mSql = "SELECT * FROM FOR"
mCursorFOR = SQL1.ExecQuery(mSql)
mTotalRows = mCursorFOR.RowCount
'Clear ScrollView
Dim i As Int
For i = ScrollView1.Panel.NumberOfViews - 1 To 0 Step -1
ScrollView1.Panel.RemoveViewAt(i)
Next
Bitmaps.Initialize 'Its a List
Dim i As Int
Dim b As Bitmap
Dim mTemImagem As String
i = 0
For i = 0 To mTotalRows - 1
mCursorFOR.Position = i
mTemImagem = mCursorFOR.GetString(mColNameFOR(2))
If File.Exists(File.DirRootExternal, mTemImagem) = True Then
b.InitializeSample(File.DirRootExternal, mTemImagem, 160dip, 160dip)
Bitmaps.Add(b)
End If
ToastMessageShow(i,False)
Next
'Part of Sample ScrollView
For i = 0 To Bitmaps.Size - 1
Dim iv As ImageView 'create an ImageView for each bitmap
iv.Initialize(i)
Dim bd As BitmapDrawable
bd.Initialize(Bitmaps.Get(i))
iv.Background = bd 'set the background of the image view.
'add the image view to the scroll bar internal panel.
ScrollView1.Panel.AddView(iv, 5dip, 5dip + i * 160dip, ScrollView1.Width - 10dip, 150dip)
Next
End Sub
---
Thanks for any help
Last edited by a moderator: