Merge "Fix issue #3149290: java.lang.RuntimeException: Unable to pause activity" into gingerbread

This commit is contained in:
Dianne Hackborn
2010-12-15 12:56:53 -08:00
committed by Android (Google) Code Review

View File

@@ -963,7 +963,7 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
SavedState ss = new SavedState(superState);
boolean haveChildren = getChildCount() > 0;
boolean haveChildren = getChildCount() > 0 && mItemCount > 0;
long selectedId = getSelectedItemId();
ss.selectedId = selectedId;
ss.height = getHeight();
@@ -978,8 +978,12 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
// Remember the position of the first child
View v = getChildAt(0);
ss.viewTop = v.getTop();
ss.position = mFirstPosition;
ss.firstId = mAdapter.getItemId(mFirstPosition);
int firstPos = mFirstPosition;
if (firstPos >= mItemCount) {
firstPos = mItemCount - 1;
}
ss.position = firstPos;
ss.firstId = mAdapter.getItemId(firstPos);
} else {
ss.viewTop = 0;
ss.firstId = INVALID_POSITION;