我试图扩展ExpandableListView类,但得到:
android.view.InflateException
Binary XML file line #30: Binary XML file line #30: Error inflating class com.myapp.ExtendedExpandableListView
我的自定义ExpandableListView:
public class ExtendedExpandableListView extends ExpandableListView {
public ExtendedExpandableListView(Context context) {
super(context, null);
}
@Override
protected void dispatchDraw(Canvas canvas) {
try {
super.dispatchDraw(canvas);
} catch (IndexOutOfBoundsException e) {
Log.e("LOG", "Ignore list view error ->" + e.toString());
}
}
}
布局的xml中定义的元素:
<com.myapp.ExtendedExpandableListView
android:id="@+id/customListViewElement"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:animateLayoutChanges="true"
android:dividerHeight="0dp"
android:divider="@android:color/transparent"
android:groupIndicator="@null"
android:listSelector="@android:color/transparent"
android:showDividers="middle" >
</com.myapp.ExtendedExpandableListView>
在片段中膨胀:
myListView = (ExtendedExpandableListView) mView.findViewById(R.id.customListViewElement);
答案 0 :(得分:0)
问题在于XML
list
您在结束标记之前已包含<com.myapp.ExtendedExpandableListView
android:id="@+id/customListViewElement"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:animateLayoutChanges="true"
android:dividerHeight="0dp"
android:divider="@android:color/transparent"
android:groupIndicator="@null"
android:listSelector="@android:color/transparent"
android:showDividers="middle"
</com.myapp.ExtendedExpandableListView>
使用上面的标记,并在末尾删除>
标记