If File.Exists(File.DirAssets, Timage) Then
TMS2pan.SetBackgroundImage( LoadBitmap(File.DirAssets, Timage) )
Else
' Nine-Patch extension
!!! If File.Exists(File.DirAssets, Timage) = False Then
'
' If imagefile was not found in DirAssets, then it is propably a NinePatch-file
'
' Prerequisites to work properly:
' -file must be located in <project folder>\Objects\res\drawable
' -file must be "read only"
' -filename must not be longer than 8 characters
' -filename must be lowercase
' -last two characters of the filename must be ".9" (For example "picabc.9.png")
' -imagefile must have the 9patch padding information
'
Dim strNpFileName As String
Dim p As Int
p = Timage.IndexOf(".")
If p>1 Then
' To use the 9patch mechanism we need to correct the filnames
strNpFileName = Timage.SubString2(0,p)
Try
Dim r As Reflector
Dim package As String
Dim id As Int
package =r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
id =r.GetStaticField( package & ".R$drawable", strNpFileName)
r.Target =r.GetContext
r.Target =r.RunMethod("getResources")
TMS2pan.Background =r.RunMethod2("getDrawable", id, "java.lang.int")
Catch
Log("#-Error trying ToastMessageShow2 with NinePatch")
End Try
End If
!!! End If
End If