B4i Library [class] CustomListView

SS-2014-11-06_16.22.15.png


B4i implementation of CustomListView (http://www.b4x.com/android/forum/th...xible-list-based-on-scrollview.19567/#content).

Note that you should make sure that there is a live reference to all instances of CustomListView. Otherwise the instance will be released and the events will not be raised.

You can use a global variable to store a live reference.

New version was uploaded. CustomListView is implemented as a custom view. It should be added with the designer.

V1.76 uploaded. This update brings the improvements added to B4A CustomListView:
- Animated inserts.
- ResizeItem method.
- FirstVisibleIndex / LastVisibleIndex properties.
- ScrollToItem.
- ReachEnd event.
- RemoveAt / ReplaceAt methods.

The class will be included as a library in B4i v4.30.
 

Attachments

  • CustomListView.zip
    6.8 KB · Views: 507
Last edited:

jahswant

Well-Known Member
Licensed User
Longtime User
Declare all CustomListViews as process global variables and they will work properly.
I think i don't understand this very well.

I need to make something like this.

B4X:
Sub ListViewCats_ItemClick (Index As Int, Value As Object)
    Reader.Concerned = PG.Title
    Reader.Subcat = Value
    Reader.Show
End Sub

This is my show code in reader

B4X:
Public Sub Show
    Main.NavControl.ToolBarVisible = False
    btnBack.InitializeText("Previous","Previous")
    If PG.IsInitialized = False Then
        PG.Initialize("PG")
        PG.RootPanel.LoadLayout("mainreader")
        PG.RootPanel.Color = Colors.White
        pnlContent.LoadLayout("readerlayout")
        PG.HideBackButton = True
    End If
  
    Main.NavControl.ShowPage(PG)
   
     ListViewCats.Clear

    PG.Title = "Learn Arabic" & " V " & Utils.GetVersion
  
    lblMenu.Text = Concerned
  
    lblSousMenu.Text = Subcat
  
    Timer1.Initialize("Timer1",1)
      
    ImageView1.Bitmap = Utils.ResizeImage (LoadBitmap(File.DirAssets,"play.png"),ImageView1.Width,ImageView1.Height)
  
    FillListView(Concerned,Subcat)
End Sub

First time it displays correctly but when i come for the second time.Items are not displayed correctly and the third time items are not visible at all.What are the best practices when you have to do such actions ?
 
Last edited:

Alberto Iglesias

Well-Known Member
Licensed User
Longtime User
Do you have some sample to create programmatically?

I´ve tried this but not work!

B4X:
Dim clvComment As CustomListView
clvComment.Initialize(Me,"clvComment")
pnlLine.AddView(clvComment.GetBase,5dip,5dip,100%x,50dip)
clvComment.Clear

or how to get this view from layout?? Like this?

Dim clvComment As CustomListView = p.GetView(0)
 
Last edited:
Top