안드로이드 개발 질문/답변
(글 수 45,052)
mRelative = (RelativeLayout)findViewById(R.id.relative);
RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(100,100);
mRelative.setLayoutParams(lp);
위와같이 크기변경을 할려고하는데.
자꾸 런타임 오류가 나는데요
원래 되는건데..
머가 문제인지 영.모르겠어요..ㅡ.ㅡ
관련 xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#223344"
>
<TextView
android:id="@+id/tv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:background="#123456"
android:layout_alignParentTop="true"
/>
</RelativeLayout>




mRelative = (RelativeLayout)findViewById(R.id.relative); 이 부분을 체크해 보심이.... ClassCastException은 Casting을 잘못했기 때문입니다.
xml에서 R.id.relative가 RelativeLayout인지부터 체크해보세요