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

Manipulating the view hierarchy with slots #86

Description

@tymm

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions