Get ListView children that are not in view:
Step 1).Get The Count of the Listview.
int d = listView.getCount();
for (int i = 0; i < d; i++)
{
View v = getViewByPosition(i, listView);
}
Step 2)You need to create your method.
public View getViewByPosition(int position, ListView listView)
{
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (position< firstListItemPosition || position> lastListItemPosition )
{
return listView.getAdapter().getView(position, null, listView);
}
else
{
final int childIndex = position - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
Step 1).Get The Count of the Listview.
int d = listView.getCount();
for (int i = 0; i < d; i++)
{
View v = getViewByPosition(i, listView);
}
Step 2)You need to create your method.
public View getViewByPosition(int position, ListView listView)
{
final int firstListItemPosition = listView.getFirstVisiblePosition();
final int lastListItemPosition = firstListItemPosition + listView.getChildCount() - 1;
if (position< firstListItemPosition || position> lastListItemPosition )
{
return listView.getAdapter().getView(position, null, listView);
}
else
{
final int childIndex = position - firstListItemPosition;
return listView.getChildAt(childIndex);
}
}
No comments:
Post a Comment