diff options
author | Dianne Hackborn <hackbod@google.com> | 2010-12-22 18:40:56 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-12-22 18:40:56 -0800 |
commit | dd830c21149c336139b28560c0e6fba9f3d0e0fc (patch) | |
tree | 375d4c4506d690e2b34ab3990563f33ef2bc3cbe | |
parent | 182f7950b83a4aa6df8e080232c63571f20daabc (diff) | |
parent | 6023873463331d30b7ed12942c3323f1b6975ed8 (diff) | |
download | frameworks_base-dd830c21149c336139b28560c0e6fba9f3d0e0fc.zip frameworks_base-dd830c21149c336139b28560c0e6fba9f3d0e0fc.tar.gz frameworks_base-dd830c21149c336139b28560c0e6fba9f3d0e0fc.tar.bz2 |
am 60238734: am 2dda21b9: Merge "Another stab at fixing issue #3149290 java.lang.RuntimeException:..." into gingerbread
* commit '6023873463331d30b7ed12942c3323f1b6975ed8':
Another stab at fixing issue #3149290 java.lang.RuntimeException:...
-rw-r--r-- | core/java/android/widget/AbsListView.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/core/java/android/widget/AbsListView.java b/core/java/android/widget/AbsListView.java index d31acec..ab98763 100644 --- a/core/java/android/widget/AbsListView.java +++ b/core/java/android/widget/AbsListView.java @@ -1475,8 +1475,16 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te ss.position = getSelectedItemPosition(); ss.firstId = INVALID_POSITION; } else { - if (haveChildren) { - // Remember the position of the first child + if (haveChildren && mFirstPosition > 0) { + // Remember the position of the first child. + // We only do this if we are not currently at the top of + // the list, for two reasons: + // (1) The list may be in the process of becoming empty, in + // which case mItemCount may not be 0, but if we try to + // ask for any information about position 0 we will crash. + // (2) Being "at the top" seems like a special case, anyway, + // and the user wouldn't expect to end up somewhere else when + // they revisit the list even if its content has changed. View v = getChildAt(0); ss.viewTop = v.getTop(); int firstPos = mFirstPosition; |