summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@android.com> 2009-08-17 10:59:35 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2009-08-17 10:59:35 -0700
commit32b72f7a533fb63b85eca4ff28e3b801ccec9e33 (patch)
tree8c631d621e12e6e80108b30695a80515b5d95c5f
parent4a1035508fa8826b974b2954e46784a17e3bbdf2 (diff)
parentfd0d627569cb250f7060a83161cc845b9616e5a1 (diff)
am fd0d6275: Fix ExpandableListView context menus when has header views.
Merge commit 'fd0d627569cb250f7060a83161cc845b9616e5a1' * commit 'fd0d627569cb250f7060a83161cc845b9616e5a1': Fix ExpandableListView context menus when has header views.
-rw-r--r--core/java/android/widget/ExpandableListView.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/java/android/widget/ExpandableListView.java b/core/java/android/widget/ExpandableListView.java
index 536062168e61..6abb2ae4774e 100644
--- a/core/java/android/widget/ExpandableListView.java
+++ b/core/java/android/widget/ExpandableListView.java
@@ -33,6 +33,7 @@ import android.view.ContextMenu;
import android.view.SoundEffectConstants;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
+import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ExpandableListConnector.PositionMetadata;
/**
@@ -916,7 +917,14 @@ public class ExpandableListView extends ListView {
@Override
ContextMenuInfo createContextMenuInfo(View view, int flatListPosition, long id) {
- PositionMetadata pm = mConnector.getUnflattenedPos(flatListPosition);
+ // Adjust for and handle for header views
+ final int adjustedPosition = flatListPosition - getHeaderViewsCount();
+ if (adjustedPosition < 0) {
+ // Return normal info for header view context menus
+ return new AdapterContextMenuInfo(view, flatListPosition, id);
+ }
+
+ PositionMetadata pm = mConnector.getUnflattenedPos(adjustedPosition);
ExpandableListPosition pos = pm.position;
pm.recycle();