Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Manipulating the view hierarchy with slots #86

Open
tymm opened this issue Apr 25, 2016 · 0 comments
Open

Manipulating the view hierarchy with slots #86

tymm opened this issue Apr 25, 2016 · 0 comments

Comments

@tymm
Copy link

tymm commented Apr 25, 2016

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" ) ) )
    }
  }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant