I have two problems:
1. It doesn't work when you use a list with a UIGrid with a PIVOT in TOP (each element has it's pivot in top also). When it removes one item from bottom an puts on top it does later.
float distance = t.localPosition.y - center.y;
It expects that localPosition.y it's the center but sometimes it's not.
2. realIndex variable should be other thing.
See this:
http://developer.android.com/reference/android/widget/ArrayAdapter.htmlIt's a class where you provide your data and it uses with the list (MVC).
Constructor:
ArrayAdapter(Context context, int resource, T[] objects)
Method:
getView(int position, View convertView, ViewGroup parent)
Where you override it and you fill your data. "int position" it's the index within your data list.
Suppose you have a list of 3 items, indexes should be values like:
0
1
2
0
1
2
And not:
0
1
2
3
4
5
Or:
-5
-4
-3
-2
-1
So for that case you should provide something to tell how many items you have. Here you have the code i used to achieve this:
int index = 0;
if (realIndex > 0) {
int loop = 1 + (realIndex / count);
index = (loop * count) - realIndex;
index = index == count ? 0 : index;
} else {
index = -realIndex % count;
}