開發問題及解決 java lang ClassCastException android widget LinearLa
阿新 • • 發佈:2018-11-08
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
Caused by: java.lang.ClassCastException:android.widget.LinearLayout$LayoutParams
These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses of ViewGroup that are responsible for arranging their children.
So basically, if you are adding a view to another, you MUST set the LayoutParams of the view to the LayoutParams type that the parent uses, or you will get a runtime error.
我是這樣理解的,如果你要將一個view新增到另一個佈局中,你必須設定該View的佈局引數為其父類所使用的佈局引數型別。即要在程式碼中動態改變某元件的高度,其佈局引數型別應該是其父類所使用的佈局引數型別。
|