This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Manipulating the view hierarchy with slots #86
Copy link
Copy link
Open
Description
I have this strange problem which I do not understand probably due to missing knowledge of how slots or macroid in general is working.
I want to wrap a ViewGroup into another ViewGroup after a layout was set in setContentView(...).
This works but when I then want to add a TextView to the new outer ViewGroup it fails in the following way: The TextView becomes the first child of the new outer ViewGroup.
However it should be the second (last) child of the new outer ViewGroup since I add it to the new outer ViewGroup after I add the old outer ViewGroup to the new outer ViewGroup.
var newOuter = slot[FrameLayout]
var outer = slot[LinearLayout]
override def onCreate(savedInstanceState: Bundle) = {
super.onCreate(savedInstanceState)
setContentView(getUi(l[LinearLayout]() <~ matchParent <~ wire(outer)))
getUi( l[FrameLayout]() <~ matchParent <~ wire( newOuter ) )
outer.map { view ⇒
view.getParent() match {
case parent: ViewGroup ⇒
parent.removeView( view )
parent.addView( newOuter.get )
case _ ⇒ //
}
newOuter.get.addView( view )
newOuter.get.addView( getUi( w[TextView] <~ text( "This TextView should be the last child of newOuter: FrameLayout" ) ) )
}
}
Metadata
Metadata
Assignees
Labels
No labels