I was able to solve this problem by viewing the Android source code. Here is what I did:
protected void onItemClick(AdapterView<?> adapterView, int position) {
final int start = adapterView.getFirstVisiblePosition();
final int index = position - start;
final View childView = adapterView.getChildAt(index);
if (childView != null) {
adapterView.showContextMenuForChild(childView);
}
}
source
share