Android Question From dynamic generated scrollview get current pressed event

Ferdari

Active Member
Licensed User
If i create dinamically scrollview, how do i return a click event from current pressed img or button?

B4X:
For i1 = 0 To 5

            Dim img As ImageView
            img.Initialize("img")
            img.Gravity=Gravity.FILL
          
            img.Bitmap=LoadBitmap(File.DirAssets , "image.webp")
          
            Dim pnl As HorizontalScrollView
            pnl.Initialize(500dip,"scroll"&i)
            pnl.Panel.Initialize("")

            appscrollpnl.Panel.AddView(pnl,10dip,topanel, Activity.Width - 20dip, 80dip)

            pnl.Panel.Width=480dip
            pnl.Width=Activity.Width-20dip
          
            pnl.Panel.AddView(img,left,0,80dip,80dip)
          
            left=left + 80dip
 Next
i want to do a sub that return the currently clicked, for ex the imgview pressed event for the pressed img.
or set another properties to imgview pressed by the event.

i was thinking doing a shared sub like
B4X:
Sub img_Click()
   Self.width(300dip) or this.width(300dip) or sender.width(300dip)
End
Thanks.
 
Last edited:

Ferdari

Active Member
Licensed User
Duid you ever read the documentation or searched the forum before asking a question?
B4X:
Dim img As ImageView
img.Initialize("img")
B4X:
Sub img_Click()
  dim img as ImageView = sender
  ' work with img
End
Thanks @DonManfred, its working like charm, i haven't read the documentation, i work with too much programming languages.

Also im using your Stickers4Whats lib, its very good work,

this script generates dynamically the sticker packs, first, it reads the JSON file, then creates a horizontalscrollview with 6 images in pack + add to wa button for every sticker pack, i was working on this all day.

How are you doing to show the sticker packs in app?

i will send you a donation tomorrow(wed) ;)
 

DonManfred

Expert
Licensed User
How are you doing to show the sticker packs in app?
You should create a new thread for a new question. Additionally it is not related to this thread.

i´m not showing any Stickers. I just wrote the wrap as per request. I just use it in a private app to realize my own set of stickers in Whatsapp.
 

Ferdari

Active Member
Licensed User
Just wanting to show what is achieved:


this list was generated from the JSON, from 15 packs, 385 images, now all works
 
Last edited:
Top