You are here

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

I spent a few hours debugging this exception in an Android app. When you create a new View you usually set its [geshifilter-code]LayoutParams[/geshifilter-code]. The trick is that you need you use the Type of [geshifilter-code]LayoutParams[/geshifilter-code] that is from the parent view's class. So if you're adding a [geshifilter-code]LinearLayout[/geshifilter-code] to a [geshifilter-code]FrameLayout[/geshifilter-code], you need to set [geshifilter-code]LayoutParams[/geshifilter-code] to an instance of [geshifilter-code]FrameLayout.LayoutParams[/geshifilter-code].

Tags: 

Add new comment

Simple Copyright Policy: If you want to reproduce anything on this site, get my permission first.