Android 2级自定义可扩展列表视图ClassCastException

Android 2级自定义可扩展列表视图ClassCastException,android,expandablelistview,classcastexception,baseadapter,Android,Expandablelistview,Classcastexception,Baseadapter,我已经成功地掌握了在子行和子行中自定义布局的两级ExpandableListView。问题是第一级的组标题显示良好。由于第一级ExpandableListView的高度,第二级的行部分显示。 第一级ExpandableListView承载一个布局,而此布局承载另一个ExpandableListView,后者又承载一个自定义布局,该布局具有tableRow,数据应从中动态填充 我回顾了位于的教程,建议使用将在第一级ExpandableListView的适配器中使用的自定义ExpandableLis

我已经成功地掌握了在子行和子行中自定义布局的两级ExpandableListView。问题是第一级的组标题显示良好。由于第一级ExpandableListView的高度,第二级的行部分显示。 第一级ExpandableListView承载一个布局,而此布局承载另一个ExpandableListView,后者又承载一个自定义布局,该布局具有tableRow,数据应从中动态填充

我回顾了位于的教程,建议使用将在第一级ExpandableListView的适配器中使用的自定义ExpandableListView

class CustomExpandableListView extends ExpandableListView {
public CustomExpandableListView(Context context) {
super(context);     
}

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
/*
* Adjust height
*/
heightMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }  
}
但是当我替换第一级ExpandableListView的行时,我在尝试扩展第一级ExpandableListView时遇到了ClassCastException

class CustomExpandableListView extends ExpandableListView {
public CustomExpandableListView(Context context) {
super(context);     
}

protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
/*
* Adjust height
*/
heightMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }  
}
以下是在第一级Epandable列表视图中不使用CustomExpandableListview类时的代码:

public View getChildView(int groupPosition, int childPosition,
        boolean isLastChild, View convertView, ViewGroup parent) {
ExpandableListView elv = (ExpandableListView) 
v.findViewById(R.id.eLV_bols_details_goods_list_item);
    ExpandableListAdapterGoodsSub eLVGoodsSub = new ExpandableListAdapterGoodsSub(context, gs.getGoodsDetailSegment());
    elv.setAdapter(eLVGoodsSub);
.
.
.
下面是我将要使用的代码,以便第一级ExpandableListView不会部分隐藏内部ExpandableListView

CustomExpandableListView elv = (CustomExpandableListView) v.findViewById(R.id.eLV_bols_details_goods_list_item);

    ExpandableListAdapterGoodsSub eLVGoodsSub = new ExpandableListAdapterGoodsSub(context, gs.getGoodsDetailSegment());
    elv.setAdapter(eLVGoodsSub);
ClassCastException的问题已经解决了

CustomExpandableListView elv = (CustomExpandableListView) v.findViewById(R.id.eLV_bols_details_goods_list_item);
替换代码

CustomExpandableListView elv = (CustomExpandableListView) v.findViewById(R.id.eLV_bols_details_goods_list_item);


它不显示内部ExpandableListView。innerExpandable listView使用带有TableRow的自定义布局。此方法用于显示没有自定义布局的默认ExpandableListView