summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2010-12-15 12:56:53 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-15 12:56:53 -0800
commit7daaa98c6531373a2a742c1360f0a2795de0619f (patch)
tree045a653d311d72d8c1ac06bab11bee4f2193698a
parent52078255dacabe9b779613b032a4dc3706b2b5d3 (diff)
parent99441c45e48abd118bd38da6f0844750a710cd33 (diff)
downloadframeworks_base-7daaa98c6531373a2a742c1360f0a2795de0619f.zip
frameworks_base-7daaa98c6531373a2a742c1360f0a2795de0619f.tar.gz
frameworks_base-7daaa98c6531373a2a742c1360f0a2795de0619f.tar.bz2
Merge "Fix issue #3149290: java.lang.RuntimeException: Unable to pause activity" into gingerbread
-rw-r--r--core/java/android/widget/AbsListView.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java
index 9a38acc..8e8b830 100644
--- a/core/java/android/widget/AbsListView.java
+++ b/core/java/android/widget/AbsListView.java
@@ -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;