안드로이드 개발 질문/답변
(글 수 45,052)
<RelativeLayout>
<ImageView>
<CustomImageView>
</RelativeLayout>
이렇게 하면 오류가 나오고
<RelativeLayout>
<CustomImageView>
<ImageView>
</RelativeLayout>
이렇게 하면 잘 돌아가네요
오류 내용은 java.lang.ClassCastException: android.widget.ImageView connot be cast to CustomImageView
본문내용은
imageview = (ImageView)findViewById(R.id.imageview);
customimageview = (CustomImageView)findViewById(R.id.customimageview);
인데 cast에서 틀린건 없는거 같구요
단지 imageview를 위로 올리려고 했을 뿐인데 안되니까 답답하네요
2012.09.19 18:05:54
위에는 반대로 써놨네요
<RelativeLayout>
<ImageView>
<CustomImageView>
</RelativeLayout>
이게 잘 돌아가고
<RelativeLayout>
<CustomImageView>
<ImageView>
</RelativeLayout>
이게 오류를 뱉네요
xml는 트리만 작성해보겠습니다
<RelativeLayout>
<RelativeLayout>
<ImageView />
<CustomImageView />
</RelativeLayout>
<RelativeLayout>
<Button />
<Button />
</RelativeLayout>
<RelativeLayout>
<Button />
<Button />
<Button />
</RelativeLayout>
</RelativeLayout>
컨트롤 c 컨트롤 v 말고 전체소스를 .xml에 다 작성하신건가요? 아니라면 지우고 다시 해보시죠