Android Question AHSwipeToRefresh, CustomListView scroll problem

Discussion in 'Android Questions' started by rscheel, Jul 14, 2017.

  1. rscheel

    rscheel Well-Known Member Licensed User

    Generate a small project where I am using the CustomListView, Cardview and AHSwipeToRefresh libraries, it works well when recharging but when I go to the list and then I want to go back to the beginning of the list always generates the reload, I attached the test in case someone can help me solve it .


    Attached Files:

    Last edited: Jul 15, 2017
  2. rscheel

    rscheel Well-Known Member Licensed User

    An estimated help on this, thank you very much.
  3. rscheel

    rscheel Well-Known Member Licensed User

    After giving several laps to the code, I managed to make it work correctly, I share the code in case someone wants to use it.

    Thanks to those who took the trouble to comment ;).

    Sub Process_Globals
    Dim tm As Timer
    End Sub

    Sub Globals
    Private CustomList As CustomListView
    Private CardView As CardView 'I believe in the designer LayoutCellItem
        Dim STR As AHSwipeToRefreshMulti  'I believe in the designer LayoutMain
        Private PanelListView As Panel
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    Array As Int (Colors.Red, Colors.Blue, Colors.Green, Colors.Cyan, Colors.Magenta, Colors.Yellow))
    Dim l As List
        STR.SwipeableChilden = l
    End Sub

    Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
    Dim p As Panel
    'we need to add the panel to a parent to set its dimensions. It will be removed after the layout is loaded.
        Activity.AddView(p, 00, Width, Height)
    'label1 and button1 will point to the last added views.
        Return p
    End Sub

    Sub CargaLista
    For i = 1 To 100
    $"Item #${i}"$, CustomList.AsView.Width, 100dip), 112dip$"Item #${i}"$)
    End Sub

    Sub STR_Refresh
    Log("Refresh started")
    'Start the timer. Normally you will start your asynchronous job here
        tm.Enabled = 
    'Disable the STR object so we can not start a new refresh process
        STR.Enabled = True
    End Sub

    'The timer tick simulates the end of the refreshing process
    Sub Timer_Tick
    Log("Refresh stopped")
    'Stop Timer and refresh the listview data
        tm.Enabled = False

    'Stop the spinning disc and enable the STR object again.
        STR.Refreshing = False
        STR.Enabled = 
    End Sub

    Sub CardView_Click
    Dim index As Int = CustomList.GetItemFromView(Sender)
    ToastMessageShow("Checked items: " & CustomList.GetValue(index), False)
    End Sub
    XbNnX_507 likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice