mListView based on native ListView
differents between ListView(in b4a)
implement :
1.divider(drawable,get or set height)
2.selected drawable (differents between Usually state)
3.scroll event(use to do something like:load next page,load last page,judge with this event)
4.FooterView and HeaderView
how to code:
b4amListView
Author: IceFairy333
Version: 1.2
differents between ListView(in b4a)
implement :
1.divider(drawable,get or set height)
2.selected drawable (differents between Usually state)
3.scroll event(use to do something like:load next page,load last page,judge with this event)
4.FooterView and HeaderView
how to code:
B4X:
'must like ListView
dim lv as mListView
lv.Initialize("lv")
Activity.AddView(lv,0,0,-1,-1)'-1=matchparent,-2=wrapcontent
Dim itbg,itbgp As BitmapDrawable
itbg.Initialize(LoadBitmap(File.DirAssets,"itbg.9.png"))
itbg.Gravity=Gravity.FILL
itbgp.Initialize(LoadBitmap(File.DirAssets,"itbgp.9.png"))
itbgp.Gravity=Gravity.FILL
lv.SingleLineLayout.Background=itbg
lv.SingleLineLayout.Label.TextSize=20
lv.SingleLineLayout.Label.TextColor=Colors.ARGB(255,255,71,65)
lv.SingleLineLayout.SelectedBackground=itbgp
Dim cd As ColorDrawable
cd.Initialize(Colors.Red,5)
lv.Divider=cd
lv.DividerHeight=1dip
Dim lbh,lbf As Label
lbh.Initialize("")
lbh.Text="Header"
lbf.Initialize("")
lbf.Text="Footer"
lv.AddFooterView(lbf)
lv.AddHeaderView(lbh)
lv.SetData'call this after footer and header,must before you add any
'data in listview
For i=1 To 200
lv.AddSingleLine2("项目名称:"&i,"项目名称:"&i)
Next
b4amListView
Author: IceFairy333
Version: 1.2
Fields:- Background As Drawable
- Label As LabelWrapper
- SecondLabel As LabelWrapper
- SelectedBackground As Drawable
- ItemHeight As Int
Fields:- Background As Drawable
- ImageView As ImageViewWrapper
- Label As LabelWrapper
- SecondLabel As LabelWrapper
- SelectedBackground As Drawable
- ItemHeight As Int
Fields:- Background As Drawable
- Label As LabelWrapper
- SelectedBackground As Drawable
- ItemHeight As Int
- mListView
Events:- itemclick (Position As Int, Value As Object)
- itemlongclick (Position As Int, Value As Object)
- onscroll (view as Object As , firstVisibleItem as int As , visibleItemCount as int As , totalItemCount as int As )
- onscrollstatechanged (view as Object As , scrollState as int As )
- Status_scroll_begin As Int
- Status_scroll_end As Int
- nCurSel As Int
- AddFooterView (vf As View)
call this before SetData - AddHeaderView (vh As View)
call this before SetData - AddSingleLine (Text As String)
- AddSingleLine2 (Text As String, ReturnValue As Object)
- AddTwoLines (Text1 As String, Text2 As String)
- AddTwoLines2 (Text1 As String, Text2 As String, ReturnValue As Object)
- AddTwoLinesAndBitmap (Text1 As String, Text2 As String, Bitmap As Bitmap)
- AddTwoLinesAndBitmap2 (Text1 As String, Text2 As String, Bitmap As Bitmap, ReturnValue As Object)
- BringToFront
- Clear
- GetItem (Index As Int) As Object
- GetSelection As Int
- Initialize (arg1 As String)
- Invalidate
- Invalidate2 (arg0 As Rect)
- Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- IsInitialized As Boolean
- RemoveAt (Index As Int)
if index=nCurSel then nCurSel=-1 - RemoveView
- RequestFocus As Boolean
- SendToBack
- SetBackgroundImage (arg0 As Bitmap)
- SetData
- SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
- SetSelection (Position As Int)
- Background As Drawable
- Color As Int [write only]
- Divider As Drawable
- DividerHeight As Int
- Enabled As Boolean
- FastScrollEnabled As Boolean
- Height As Int
- Left As Int
- ScrollingBackgroundColor As Int [write only]
- SingleLineLayout As SingleLineLayout [read only]
- Size As Int [read only]
- Tag As Object
- Top As Int
- TwoLinesAndBitmap As TwoLinesAndBitmapLayout [read only]
- TwoLinesLayout As TwoLinesLayout [read only]
- Visible As Boolean
- Width As Int
Attachments
Last edited: