Nine Patch Images

tchart

Well-Known Member
Licensed User
Longtime User
Hi

Ive read this;

http://www.b4x.com/forum/basic4andr...torials/14283-nine-patch-images-tutorial.html

The tutorial uses resources that are included in the application.

Im trying to implement a button with a built in Android resource ie btn_minus, btn_plus etc

Ive tried to do this;

bd = ph.GetResourceDrawable(17301511)
sld.AddState(sld.State_Disabled, bd)

But since the resource is a nine patch image it throws an error.

So how can I implement a button with a standard Android resource?

Thanks
 

tchart

Well-Known Member
Licensed User
Longtime User
Hi Erel

Here is the code;

Dim ph As Phone
Dim bd As BitmapDrawable

bd = ph.GetResourceDrawable(17301580)
Activity.AddMenuItem2 ("Zoom In", "ZoomIn", bd.Bitmap )

bd = ph.GetResourceDrawable(17301577)
Activity.AddMenuItem2 ("Zoom Out", "ZoomOut", bd.Bitmap )

bd = ph.GetResourceDrawable(17301560)
Activity.AddMenuItem2 ("Exit", "Exit", bd.Bitmap )

Dim Button1 As Button
Button1.Initialize("")

Dim sld As StateListDrawable
sld.Initialize

bd = ph.GetResourceDrawable(17301746) '<- This line fails
sld.AddState(sld.State_Disabled, bd)

The menus are created fine but the line indicated fails - however if I use of of the constants from the menus (eg 17301560) it works fine.

Any help would be great!
 
Upvote 0

Similar Threads

Replies
4
Views
885
D
  • Question
Replies
11
Views
1K
Deleted member 103
D
Top