注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

沉默蜂B4A安卓编程

国内资料最全的B4A资料库

 
 
 

日志

 
 

[滑动开关库]SlideSwitch V1.0.2  

2015-09-27 21:37:46|  分类: 官网类库 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

[滑动开关库]SlideSwitch V1.0.2 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
运行效果图


[滑动开关库]SlideSwitch V1.0.2 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
编译时的错误提示


如果编译时提示上面所示情况,将C:\AndroidSDK\android-sdk-windows\extras\android\support\v4\android-support-v4.jar复制到Libraries文件夹。android-support-v4.jar是android界面特殊效果的第三方的jar包,比如滑动效果,貌似在3.0以后就自带了,不需要手动加载 。


#Region  Project Attributes 
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName: 
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
'#AdditionalRes: ..\resources
#End Region

#Region  Activity Attributes 
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Private ssw1 As SlideSwitch
Private ssw2 As SlideSwitch
Private ssw3 As SlideSwitch
Private ssw4 As SlideSwitch
Private ssw5 As SlideSwitch
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
ssw1.Color = Colors.Blue
ssw1.State = True
ssw1.Token = 1
ssw2.Color = Colors.Red
ssw2.Rounded = True
ssw2.Token = 2
ssw3.Color = Colors.Magenta
ssw3.Rounded = True
ssw3.Token = 3
ssw4.Color = Colors.Yellow
ssw4.Token = 4

ssw5.Color = Colors.Cyan
ssw5.Rounded = True
ssw5.State = True
ssw5.Token = 5
'SetNinePatchDrawable(ssw5,"a9p_09_11_00549")

End Sub
Sub slideswitch_open(swview As Object,token As Object)
Log("Slide  OPEN (Token = "&token&")")
If swview Is SlideSwitch Then
Dim ssw As SlideSwitch = swview
ssw.Color = Colors.ARGB(Rnd(100, 150),Rnd(20, 800),Rnd(80, 160),Rnd(161, 255))
End If
End Sub
Sub slideswitch_close(swview As Object,token As Object)
Log("Slide CLOSE (Token = "&token&")")
If swview Is SlideSwitch Then
Dim ssw As SlideSwitch = swview
ssw.Color = Colors.ARGB(Rnd(100, 150),Rnd(20, 800),Rnd(80, 160),Rnd(161, 255))
End If
End Sub

Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub


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)
   idPressed = r.GetStaticField(package & ".R$drawable", PressedImage)
   r.Target = r.GetContext
   r.Target = r.RunMethod("getResources")
   Dim sd As StateListDrawable
   sd.Initialize
   sd.AddState(sd.State_Pressed, r.RunMethod2("getDrawable", idPressed, "java.lang.int"))
   sd.AddCatchAllState( r.RunMethod2("getDrawable", idDefault, "java.lang.int"))
   Btn.Background = sd
End Sub

Sub SetNinePatchDrawable(Control As View, ImageName As String)
   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", ImageName)
   r.Target = r.GetContext
   r.Target = r.RunMethod("getResources")
   Control.Background = r.RunMethod2("getDrawable", id, "java.lang.int")
End Sub

  评论这张
 
阅读(173)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017