I've tried but the same result. Now in DDMS log I have:

java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams



----- Original Message ----- 
From: "Peli" <peli0...@googlemail.com>
To: "Android Developers" <android-developers@googlegroups.com>
Sent: Sunday, January 11, 2009 3:39 AM
Subject: [android-developers] Re: Change linear layout programmatically - 
problem



There's this suspicious line:
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams

Have you tried to explicitly write:
LinearLayout.LayoutParams
instead of just
LayoutParams
whereever it appears?

(because each Layout has their own set of LayoutParams that are not
necessarily compatible with each other).

Peli
www.openintents.org

On 10 Jan., 23:13, EvgenyV <evgen...@gmail.com> wrote:
> Hi!
>
> I'm trying to change height layout from "wrap_content" to
> "fill_parent" from code. Using landscape mode.
> public class BBB extends Activity
> {
> @Override
> public void onCreate(Bundle savedInstanceState) {
> super.onCreate(savedInstanceState);
> setContentView(R.layout.bbb);
> LinearLayout layout = (LinearLayout)findViewById(R.id.mainZZZ);
>
> LayoutParams params = new LayoutParams
> (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
> layout.setLayoutParams(params);
> }}
>
> I have bbb.xml layout file
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
> android:orientation="vertical"
> android:id="@+id/mainZZZ"
> android:layout_width="fill_parent"
> android:layout_height="wrap_content">
> </LinearLayout>
>
> Why the activity can't be loaded after run-time changes?
> Missing I something?
>
> Thanks in advance,
> Evgeny
>
> Stack error:
> 01-10 21:53:41.570: WARN/dalvikvm(1680): threadid=3: thread exiting
> with uncaught exception (group=0x40010e28)
> 01-10 21:53:41.581: ERROR/AndroidRuntime(1680): Uncaught handler:
> thread main exiting due to uncaught exception
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680):
> java.lang.ClassCastException: android.view.ViewGroup$LayoutParams
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.LinearLayout.measureVertical(LinearLayout.java:323)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.View.measure(View.java:6621)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.View.measure(View.java:6621)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.LinearLayout.measureVertical(LinearLayout.java:461)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.LinearLayout.onMeasure(LinearLayout.java:275)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.View.measure(View.java:6621)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2791)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.widget.FrameLayout.onMeasure(FrameLayout.java:208)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.View.measure(View.java:6621)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.ViewRoot.performTraversals(ViewRoot.java:620)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.view.ViewRoot.handleMessage(ViewRoot.java:1103)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.os.Handler.dispatchMessage(Handler.java:88)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.os.Looper.loop(Looper.java:123)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> android.app.ActivityThread.main(ActivityThread.java:3742)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> java.lang.reflect.Method.invokeNative(Native Method)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> java.lang.reflect.Method.invoke(Method.java:515)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
> (ZygoteInit.java:739)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
> 01-10 21:53:41.841: ERROR/AndroidRuntime(1680): at
> dalvik.system.NativeStart.main(Native Method)


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to