I'd like to use the ImageViewTopCrop class described in this question:
My custom view is based on this code:
Here is a layout file using this custom view:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_background"
android:background="#000"
android:orientation="vertical">
<FrameLayout
android:id="@+id/details_frame"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6">
<com.grayraven.imagetest.ImageViewTopCrop
android:id="@+id/grid_item_image"
android:src="@drawable/hobbit"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
Here's how I'm trying to display it in code:
com.grayraven.imagetest;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.widget.ImageView;
import android.widget.TextView;
import com.squareup.picasso.Picasso;
public class DetailsActivity extends ActionBarActivity {
private TextView titleTextView;
private com.grayraven.imagetest.ImageViewTopCrop imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details_view);
ActionBar actionBar = getSupportActionBar();
actionBar.hide();
String title = getIntent().getStringExtra("title");
String imageUrl = getIntent().getStringExtra("imageUrl");
titleTextView = (TextView) findViewById(R.id.title);
imageView = (com.grayraven.project1.ImageViewTopCrop) findViewById(R.id.grid_item_image);
//Exception thrown here:
//android.widget.ImageView cannot be cast to com.grayraven.imagetest.ImageViewTopCrop
//can't go any further
}
}
What simple thing am I missing?