I need help for Class Example

awama

Active Member
Licensed User
Longtime User
Hi all,

I'm not familiar with "class" technology, so I need help for following problem:
I want to programmatically add buttons like this example,

Sub Globals
Dim map1 as Map
end Sub

...

RasterAnzX = 3
RasterAnzY = 4

For x = 0 To RasterAnzX - 1
For y = 0 To RasterAnzY - 1
' i = i + 1
Dim btn As Button
btn.Initialize("Button") 'All buttons share the same event sub
Activity.AddView(btn, x*50 , y*50 , 50, 50)
Next
Next

...

each button should be draggable. What I have to change in erels example from this post:
http://www.b4x.com/forum/basic4android-updates-questions/18395-classes-soon-coming.html

Can anyone help me please. Many thanks.
Walter
 
Most of the subs are pretty modular and you should be able to delete the ones you don't need. Just keep Class_Globals, Initialize, AddButton, Button_Click, Button_Touch, GetText/SetText(If needed), GetViews/GetView(If Needed), Enabled(If Needed), GetCharSize, and SetNinePatchDrawable.

You'll just need the 2 button png files too then. Should make it easier to manage. Since I use a label to draw the button you already have click and touch events you can enhance for dragging.
 
Upvote 0
Back
Top