Reputation: 526
I have a class named CropImageView
which is extended from ImageView
. but the statement below makes castException
:
CropImageView image = (CropImageView) findViewById(R.id.image);
here is the xml file:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView android:id="@+id/image"
android:background="#55000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0dip"
android:layout_y="0dip"/>
</RelativeLayout>
</FrameLayout>
do you have any suggestion?
Upvotes: 1
Views: 97
Reputation: 93173
You should use the CropImageView
canonical name in the XML
. Something like:
<your.package.CropImageView
android:id="@+id/image"
android:background="#55000000"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_x="0dip"
android:layout_y="0dip"/>
Upvotes: 1
Reputation: 33904
Try using <com.your.package.CropImageView />
instead of an <ImageView />
in your layout.
Upvotes: 1