안드로이드 개발 질문/답변 
    (글 수    45,052)
        	
        
        
    안녕하세요 도움을 받고자 이렇게 글을 쓰네요.
resource 에
<LinearLayout
android:id="@+id/event_group"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="630dip"
android:layout_marginLeft="70dip"
android:orientation="vertical"
>
...........
</LinearLayout>
event_group id 에 LinearLayout 으로 지정해 놓고
실제 coding source 에서
private LinearLayout mGroupEvent;
......
mGroupEvent = (LinearLayout) findViewById(R.id.event_group);
.......
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mGroupEvent.getLayoutParams();
위에서 mGroupEvent.getLayoutParams(); 이 실행될때 아래와 같은 error 가 발생하고 있습니다.
ERROR/AndroidRuntime(130): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManagerPolicy
ERROR/AndroidRuntime(130): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
Lockscreen 쪽이라 System process 로 돌고 있는 것 같은데요 resource에도 LinearLayout 으로 선언했고, 객체도 LinearLayout 으로
생성해 놓았는데 getLayoutParams() 을 호출할 때 왜 RelativeLayout 에서 LinearLayout 으로 casting 할려고 하는지 이해가 안되네요
다른 Test app 에서는 위의 코드가 정상적으로 처리가 되고 있는데 말이죠.
 
몇일째 이 문제로 머리가 아프네요.
도움 부탁드립니다.
감사합니다.
                                
                            resource 에
<LinearLayout
android:id="@+id/event_group"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="630dip"
android:layout_marginLeft="70dip"
android:orientation="vertical"
>
...........
</LinearLayout>
event_group id 에 LinearLayout 으로 지정해 놓고
실제 coding source 에서
private LinearLayout mGroupEvent;
......
mGroupEvent = (LinearLayout) findViewById(R.id.event_group);
.......
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) mGroupEvent.getLayoutParams();
위에서 mGroupEvent.getLayoutParams(); 이 실행될때 아래와 같은 error 가 발생하고 있습니다.
ERROR/AndroidRuntime(130): *** FATAL EXCEPTION IN SYSTEM PROCESS: WindowManagerPolicy
ERROR/AndroidRuntime(130): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
Lockscreen 쪽이라 System process 로 돌고 있는 것 같은데요 resource에도 LinearLayout 으로 선언했고, 객체도 LinearLayout 으로
생성해 놓았는데 getLayoutParams() 을 호출할 때 왜 RelativeLayout 에서 LinearLayout 으로 casting 할려고 하는지 이해가 안되네요
다른 Test app 에서는 위의 코드가 정상적으로 처리가 되고 있는데 말이죠.
몇일째 이 문제로 머리가 아프네요.
도움 부탁드립니다.
감사합니다.
                2011.03.24 10:02:15                            
            
                        
            mGroupEvent.getLayoutParams();
                                
            이렇게 하면 mGroupEvent 이 속한 layout 형태의 layoutParam이 리턴됩니다.
즉, mGroupEvent 이 뭐든간에 RelativeLayout 안에 있는거라면 RelativeLayout$LayoutParams 이 리턴되겠죠.
mGroupEvent가 LinearLayout 이라면 mGroupEvent.getLayoutParams(); 가 LinearLayout$LayoutParams 을 리턴하는게 아니라
mGroupEvent 의 자식view.getLayoutParams(); 가 LinearLayout$LayoutParams 를 리턴합니다.










