Style a SW button from a designer button

Bas Hamstra

Member
Licensed User
Longtime User
I need 26 sweet image buttons for a keyboard in Hangman game. Therefore I created 1 dummy StateListDrawable dummy button with nice images in the designer. Now I want to create 26 new buttons in software by copying the dummy button from the designer. Seems not possible?

dim Letter(27) as Button

For n=1 to 26
..Letter(n) = DesignerButton
Next

It seems only the reference is assigned, which I can understand with my C background. But in C/C++ you could dereference an object by *Letter(n) = *DesignerButton effectively making a copy of the source object. Is such a thing possible in B4A?

Thanks in advance for your patience,

Bas Hamstra
 

krokiz

Member
Licensed User
Longtime User
The order is important. The first matching state is chosen. You should therefore add Pressed state before Enabled.

This is perhaps the most useful comment on the matter about the states' order! Still if you make a clear example about the PROPER order of these states so everyone could learn it once and for all, it would be absolutely great!

So far, I am happy with the following order:

Dim stdBitmap As StateListDrawable

stdBitmap.Initialize
stdBitmap.AddState (stdBitmap.State_Pressed, bdwPressed)
stdBitmap.AddState (stdBitmap.State_Enabled, bdwEnabled)
stdBitmap.AddState (stdBitmap.State_Disabled, bdwDisabled)
stdBitmap.AddCatchAllState (bdwDisabled)

Whenever I Enable or Disable or Click on the button, its behaviour is as expected.

In conclusion: we all expect the full list of the proper ordering the AddState.
 
Upvote 0
Top