[问题] 想把 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