[問題] 想把 xml layout 裝進自訂的class中

作者: issuemylove (NotLove)   2014-05-21 11:02:34
各位大大好
我想寫一個
Class MyLayoutView extends RelativeLayout{ ...}
後來我想要把它的子View從xml中實作出
<RelativeLayout> ...子View在這裡 ... </RelativeLayout>
可是這樣用 inflater inflate 出 view 再加進我的 MyLayoutView 的話
這樣 RelativeLayout就多一層了 囧
要怎樣讓我自訂的view透過類似 Activity中的 setContentView()
直接assign 給它呢?
例如在 MyLayoutView 的 constructor中
public MyLayoutView(){
this = xml的layout;
}
謝謝!
作者: issuemylove (NotLove)   2014-05-21 11:08:00
而不像是 addView() 多一層layout
作者: Ansaga (奈燦)   2014-05-21 12:32:00
是說想塞個空的view再replace掉嗎?你要不要把他寫成fragment用fragmentmanager replace掉
作者: issuemylove (NotLove)   2014-05-21 17:34:00
研究fragment中..QQ

Links booklink

Contact Us: admin [ a t ] ucptt.com