Well, I have a floating button in my view that prints out all the items that are in my listView. What happens is that when I click the floating button it takes a photo of the first 3 items and does not take away the rest, but in the end updates the listView to the next items. It looks like the code to get print is faster than updating the listView. When I click the floating button the screenShot function is called.
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE){
printScreen();
}
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
public void screenShot (){
if (list.getFirstVisiblePosition() == 0) {
printScreen();
} else {
list.smoothScrollToPosition(0);
}
}
public void printScreen(){
int lastPosition = list.getLastVisiblePosition();
int j = list.getFirstVisiblePosition();
for (int i = j; i < lastPosition; i++){
if (list.getChildAt(i) != null && list.getChildAt(i).isEnabled()) {
JUtil.saveScreenShot(list.getChildAt(j), "operadora" + j + ".png");
}
}
list.setSelection(lastPosition);
}