I’m populating expanded list view by extending BaseExpandableListAdapter.
Code for ChildView:
public View getChildView(final int groupPosition, final int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater in=getLayoutInflater();
convertView=in.inflate(R.layout.details, null);
//set text for various TextViews from ArrayList1
return convertView;
}
Code for GroupView:
public View getGroupView(final int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
LayoutInflater li= getLayoutInflater();
convertView=li.inflate(R.layout.list, null);
//add data to ArrayList1 and set text for various TextViews
return convertView;
}
If a group is expanded and I long press on any of the subsequent group the onItemLongClick method gets (actual index + 1) value for parameter itemIndex. Because of this i get arrayindexoutofbounds exception.
elview.setOnItemLongClickListener(new OnItemLongClickListener() {
public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
final int itemIndex, long arg3) {
Log.e("index selected", itemIndex+"");
return false;
}});
Am i missing something here?
I don’t see you registering the adapter for a context menu…
Here’s the bits from how I’ve done it without issue:
adapter creation
context menu and action
You can also check out this SO question for further details.
Hope this helps.