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

沉默蜂B4A安卓编程

国内资料最全的B4A资料库

 
 
 

日志

 
 

列表类控件例程CheckListDemo4  

2014-08-24 11:39:40|  分类: 官网类库 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
列表类控件例程CheckListDemo4 - 沉默蜂 - 沉默蜂B4A安卓编程实战资料
例程效果图 



此博客日志只是MAIN模块的代码,例程中涉及到的ClsCheckList类模块代码见 《 注解类模块ClsCheckList代码 》
更多信息参考博客日志:《 可用于设置界面的检查框列表类CheckList   和 《 自定义列表视图_CustomListView 》 



#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: CheckList demo
#VersionCode: 1
#VersionName: 
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

'Activity module
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.
Dim svList As ScrollView '滚动面板
Dim lst As ClsCheckList
Dim edtFilter1, edtFilter2 As EditText '过滤关键字的输入框
Dim LogicOper As Spinner '不可编辑下拉列表框
End Sub


'绘制屏幕背景的渐变色
Sub ChangeColor(Color As Int)

Dim gd As GradientDrawable
Dim C(2) As Int
C(0) = Color
C(1) = Colors.Black
gd.Initialize("TL_BR", C)
Activity.Background = gd
End Sub

Sub Activity_Create(FirstTime As Boolean)

' Colored background
Activity.LoadLayout("main4.bal")
ChangeColor(Colors.Blue)

' List generation
lst.Initialize( Me, svList, "", "", "", 1dip)
lst.AddItemNoChkbx("A", "android", "", Null)
lst.AddItemNoChkbx("B", "basic", "", Null)
lst.AddItemNoChkbx("C", "count", "", Null)
lst.AddItemNoChkbx("D", "delta", "", Null)
lst.AddItemNoChkbx("E", "example", "", Null)
lst.AddItemNoChkbx("F", "for", "", Null)
lst.AddItemNoChkbx("G", "golf", "", Null)
lst.AddItemNoChkbx("H", "hotel", "", Null)
lst.AddItemNoChkbx("I", "integer", "", Null)
lst.AddItemNoChkbx("J", "java", "", Null)
lst.AddItemNoChkbx("K", "kilo", "", Null)
lst.AddItemNoChkbx("L", "list", "", Null)
lst.AddItemNoChkbx("M", "micro", "", Null)
lst.AddItemNoChkbx("N", "null", "", Null)
lst.AddItemNoChkbx("O", "once", "", Null)
lst.AddItemNoChkbx("P", "possible", "", Null)
lst.AddItemNoChkbx("Q", "quit", "", Null)
lst.AddItemNoChkbx("R", "radio", "", Null)
lst.AddItemNoChkbx("S", "sound", "", Null)
lst.AddItemNoChkbx("T", "through", "", Null)
lst.AddItemNoChkbx("U", "utility", "", Null)
lst.AddItemNoChkbx("V", "view", "", Null)
lst.AddItemNoChkbx("W", "width", "", Null)
lst.AddItemNoChkbx("X", "xylophone", "", Null)
lst.AddItemNoChkbx("Y", "yak", "", Null)
lst.AddItemNoChkbx("Z", "zebra", "", Null)
lst.ResizePanel

'下拉列表框填充数据
' Logical and sequential operators
LogicOper.Add("AND")
LogicOper.Add("OR")
LogicOper.Add("BEFORE")
LogicOper.Add("AFTER")
LogicOper.Add("FIRST")
LogicOper.Add("LAST")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub LogicOper_ItemClick (Position As Int, Value As Object)
edtFilter_TextChanged ("", "")
End Sub


'条件编辑框内容改变时触发此事件
Sub edtFilter_TextChanged (Old As String, New As String)
edtFilter2.Enabled = (LogicOper.SelectedIndex < 4) ' Not First or Last
If edtFilter1.Text = "" AND edtFilter2.Text = "" Then
lst.CancelFilter
Activity.Title = ""
ChangeColor(Colors.Blue)
Else
Activity.Title = lst.FilterText(0, "List_Contains") & " matching items"
ChangeColor(Colors.DarkGray)
End If
End Sub

Sub List_Contains(ID As Object, Value As Object)
If ID = Null Then ' It's a header
lst.FilterResult = True
Else
Dim S As String, Pos1, Pos2 As Int
S = Value
S = S.ToLowerCase
Pos1 = S.IndexOf(edtFilter1.Text.ToLowerCase)
If edtFilter2.Enabled Then Pos2 = S.IndexOf(edtFilter2.Text.ToLowerCase)
Select LogicOper.SelectedIndex
Case 0 ' AND
lst.FilterResult = (Pos1 <> -1 AND Pos2 <> -1)
Case 1 ' OR
lst.FilterResult = (Pos1 <> -1 OR Pos2 <> -1)
Case 2 ' BEFORE
If Pos1 <> -1 AND Pos2 <> -1 Then
lst.FilterResult = (Pos1 < Pos2)
Else
lst.FilterResult = False
End If
Case 3 ' AFTER
If Pos1 <> -1 AND Pos2 <> -1 Then
lst.FilterResult = (Pos1 > Pos2)
Else
lst.FilterResult = False
End If
Case 4 ' FIRST
If Pos1 <> -1 Then
lst.FilterResult = (Pos1 = 0)
Else
lst.FilterResult = False
End If
Case 5 ' LAST
Pos1 = S.LastIndexOf(edtFilter1.Text.ToLowerCase)
If Pos1 <> -1 Then
lst.FilterResult = (Pos1 = S.Length - 1)
Else
lst.FilterResult = False
End If
End Select
End If
End Sub

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

历史上的今天

在LOFTER的更多文章

评论

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

页脚

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