I need to create an auto scroll-able infinite list with listview where as soon as the list ends it will load the first item again. Now what I have tried so far is that I have created a infinite list by setting integer max value in count of adapter like this:
public override int Count
{
get
{
int count = this.passengerNames.Count > 2 ? int.MaxValue :this.passengerNames.Count;
return count;
}
}
Now, my list view opens up in a pop up window. So, I created a Runnable thread by creating a new class & passing its new object in listview.Post() method to auto scroll it like this:
this.passengerNameList.Post(new AutoScrollList(this, this.passengerNameList));
& my Auto scroll class is :
public class AutoScrollList : Java.Lang.Object, Java.Lang.IRunnable {
private readonly TaskFragment fragment;
private ListView passengerList;
public AutoScrollList(TaskFragment fragment, ListView passengerList)
{
this.fragment = fragment;
this.passengerList = passengerList;
}
public void Run()
{
Console.WriteLine("*** Runnable starting");
int listViewSize = this.passengerList.Adapter.Count;
for (int index = 0; index < listViewSize; index++)
{
this.passengerList.SmoothScrollToPositionFromTop(this.passengerList.LastVisiblePosition + 100, 0, 100000);
}
}
}
Now, When I try to open it the UI Hangs & if I change the max value to some random number like 400 then it works but that does not solve my purpose. Can anyone tell me if I am doing it right or not? Any help is appreciated. Thanks in advance...