Android Question Nine Patch Images error NoSuchFieldException

Peter Donovan

Member
Licensed User
Longtime User
Hi all,
I have copied my image (normal.9.png) to the <project folder>\Objects\res\drawable folder but still get this message:

java.lang.NoSuchFieldException: normal.9.png

Can anyone please tell me what I am doing wrong?

I use this line in Activity_Create(FirstTime As Boolean)

SetNinePatchButton(btn_Ok ,"normal.9.png", "pressed.9.png")

to call the Sub below


Sub SetNinePatchButton(btn As Button, DefaultImage As String, PressedImage As String)
Dim r As Reflector
Dim package As String
Dim idDefault, idPressed As Int
package = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
idDefault = r.GetStaticField(package & ".R$drawable", DefaultImage) <<------- FAILS ON THIS LINE

with this error:

java.lang.NoSuchFieldException: normal.9.png


Any assistance would be very gratefully received.

PeterD
 

Inman

Well-Known Member
Licensed User
Longtime User
Thank you thedesolatesoul, that worked perfectly. Why did it work, can you tell me please? Are all image files handled the same way?

All 9 patch PNG files are handled that way. You need to use only the part that comes before .9.png
 
Upvote 0

Similar Threads

Replies
5
Views
970
Replies
4
Views
1K
D
  • Question
Replies
11
Views
2K
Deleted member 103
D
Top