[android-developers] VideoView.setLayoutParams - ClassCastException
Hi, I have a VideoView in a LinearLayout with 2 other boxes. In trying to create a full screen video, I am doing the following: private boolean isFullScreen = false; public void onClick(View v) { VideoView vv = (VideoView) v.findViewById(R.id.videoView1); LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)vv.getLayoutParams(); if (isFullScreen) { isFullScreen = false; lp.weight = 0.2f; vv.setLayoutParams(lp); v.invalidate(); } else { isFullScreen = true; lp.weight = 0f; vv.setLayoutParams(lp); v.invalidate(); } Log.v(LogName.onClick, Video switch to + (isFullScreen ? Full screen : Normal size)); } I am getting an exception: 01-26 04:12:20.380: E/AndroidRuntime(8010): FATAL EXCEPTION: main 01-26 04:12:20.380: E/AndroidRuntime(8010): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams 01-26 04:12:20.380: E/AndroidRuntime(8010): at com.elliptictech.hdcprx.gui.PlayVideo.onClick(PlayVideo.java:54) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.view.View.performClick(View.java:2538) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.view.View$PerformClick.run(View.java:9152) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.os.Handler.handleCallback(Handler.java:587) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.os.Handler.dispatchMessage(Handler.java:92) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.os.Looper.loop(Looper.java:130) 01-26 04:12:20.380: E/AndroidRuntime(8010): at android.app.ActivityThread.main(ActivityThread.java:3691) 01-26 04:12:20.380: E/AndroidRuntime(8010): at java.lang.reflect.Method.invokeNative(Native Method) 01-26 04:12:20.380: E/AndroidRuntime(8010): at java.lang.reflect.Method.invoke(Method.java:507) 01-26 04:12:20.380: E/AndroidRuntime(8010): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 01-26 04:12:20.380: E/AndroidRuntime(8010): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) Can anyone suggest why this is the case? Alternatively, can you suggest another method to set the video view to full screen? Best regards, -jm -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] VideoView.setLayoutParams - ClassCastException
On Wed, Jan 25, 2012 at 1:25 PM, John-Marc Desmarais j...@ieee.org wrote: Can anyone suggest why this is the case? This is your code: (*LinearLayout*.LayoutParams)vv.getLayoutParams(); This is the stack trace: java.lang.*ClassCastException*: android.widget.*RelativeLayout*$LayoutParams - TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] VideoView.setLayoutParams - ClassCastException
That is a very good point. Thanks. -jm On Wed, Jan 25, 2012 at 2:33 PM, TreKing treking...@gmail.com wrote: On Wed, Jan 25, 2012 at 1:25 PM, John-Marc Desmarais j...@ieee.org wrote: Can anyone suggest why this is the case? This is your code: (LinearLayout.LayoutParams)vv.getLayoutParams(); This is the stack trace: java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams - TreKing - Chicago transit tracking app for Android-powered devices -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en