[Mono-bugs] [Bug 645249] Setting LinearLayout.LayoutParams causes a java.lang.ClassCastException

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Nov 1 23:38:56 EDT 2010


https://bugzilla.novell.com/show_bug.cgi?id=645249

https://bugzilla.novell.com/show_bug.cgi?id=645249#c1


Jonathan Pryor <jpryor at novell.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jpryor at novell.com

--- Comment #1 from Jonathan Pryor <jpryor at novell.com> 2010-11-02 03:38:55 UTC ---
Yet another case of "how does this work in Java?!"

(i.e. we need to write the equivalent Java code and see if (1) it works, and
(2) if it works, why it works.)

Android source is helpful here; specifically (on my machine),
ListView.java:1761:


    AbsListView.LayoutParams p = 
        (AbsListView.LayoutParams) child.getLayoutParams();

which implies that we should instead do:

    itemRow.LayoutParameters = new AbsLinearLayout.LayoutParams(...);

Of course, if we do that, we instead get:

E/AndroidRuntime(  831): java.lang.ClassCastException:
android.view.ViewGroup$LayoutParams
E/AndroidRuntime(  831):     at
android.widget.LinearLayout.measureHorizontal(LinearLayout.java:654)
E/AndroidRuntime(  831):     at
android.widget.LinearLayout.onMeasure(LinearLayout.java:306)

and LinearLayout.java:654:


    final LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams)
           child.getLayoutParams();

To which I say...huh?  These appear to be contradictory.  So either the C# is
wrong (and then we need to know _how_ and _why_ it's wrong), or this pattern
simply isn't permitted on Android (and the Java equivalent will fail for the
same reasons).

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list