It would be better if you could share some snippets of code ...
In any case, when it comes to ClassCastException , it means that you declare a variable of some type and assign it to another type that you defined in the XML layout file ...
for example in xml, which you might have:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Button android:layout_height="wrap_content" android:id="@+id/btn1" android:layout_width="wrap_content"> </Button> </LinearLayout>
but when connecting the component to the code:
ImageView img1 = (ImageView)context.findViewById(R.id.btn1);
This will ClassCastException bcoz, which you push a button into the ImageView variable, which, as you know, is not possible!
If this does not solve your problem, then it would be better if you publish some code fragments after figuring out which code fragment is causing the error!
source share