Weird ClassCastException: ImageView cannot be cast to ListView. In xml the view is declared as ListView. When I retrieve the object as follows:
private void initShareContextMenu() {
ListView shareListITem = (ListView) findViewById(R.id.share_list);
shareList = new ContextMenuList(shareListITem,
(RelativeLayout) findViewById(R.id.content_wrapper), this);
List<View> views = new ArrayList<View>();
views.add(findViewById(R.id.share_btn));
shareList.setViews(views);
}
I got ClassCastException. Tried to build and clean project, remove gen/bin folders, renaming the control but nothing helps. The layout looks as follows:
<RelativeLayout
android:id="@+id/content_wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<FrameLayout
android:id="@+id/youtube_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black" />
<ListView
android:id="@+id/share_list"
android:layout_width="@dimen/share_context_menu_width"
android:layout_height="wrap_content"
android:divider="@color/share_list_divider"
android:dividerHeight="1px"
android:visibility="gone" />
</RelativeLayout>
05-01 09:40:45.215: E/MessageQueue-JNI(18500): Exception in MessageQueue callback: handleReceiveCallback
05-01 09:40:46.096: E/MessageQueue-JNI(18500): java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.ListView
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at com.packagename.ui.activities.VideoPlayerActivity.initShareContextMenu(VideoPlayerActivity.java:1394)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at com.packagename.ui.activities.VideoPlayerActivity.showVideoEndScreen(VideoPlayerActivity.java:1375)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at com.packagename.ui.activities.VideoPlayerActivity.onBackPressed(VideoPlayerActivity.java:1587)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at android.app.Activity.onKeyUp(Activity.java:2193)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at android.view.KeyEvent.dispatch(KeyEvent.java:2664)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at android.app.Activity.dispatchKeyEvent(Activity.java:2423)
05-01 09:40:46.096: E/MessageQueue-JNI(18500): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent(PhoneWindow.java:1962)