I have a layout like this:
<com.mypackage.QuadPaneHorizontalSplit xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/root_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > </com.mypackage.QuadPaneHorizontalSplit>
The QuadPaneHorizontalSplit class extends QuadPaneLayout (which extends LineraLayout):
public class QuadPaneHorizontalSplit extends QuadPaneLayout { public QuadPaneHorizontalSplit(Context context) { super(context); } public QuadPaneHorizontalSplit(Context context, AttributeSet attrs) { super(context, attrs); } @TargetApi(Build.VERSION_CODES.HONEYCOMB) public QuadPaneHorizontalSplit(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected boolean isVerticalSplit() { return false; } }
After setting up the layout using setContentView, I try to get a custom view:
QuadPaneLayout quadPaneLayout = (QuadPaneLayout) findViewById(R.id.root_layout);
which works fine overall, but I got some crash reports with the following exception:
java.lang.ClassCastException: com.mypackage.QuadPaneHorizontalSplit cannot be added to com.mypackage.QuadPaneLayout
QuadPaneHorizontalSplit explicitly extends QuadPaneLayout, so an exception should not be possible. I get crash reports from Android 4.x devices and from different manufacturers. Interestingly, all devices are rooted so maybe this is a problem with some custom rom? Please note that this line of code is executed thousands of times every day without any problems, and so far I have received only 13 crashes (BugSense), but I still would like to figure this out.
I know about this: https://stackoverflow.com/a/464626/232632/ , but I do not use include for this layout, and I would not want to add a merge label because this could have unwanted effects.
Anyone have an idea what is going on here?