Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing node view on setDefaultNodeLongClickListener #170

Closed
testica opened this issue Mar 4, 2019 · 1 comment
Closed

Referencing node view on setDefaultNodeLongClickListener #170

testica opened this issue Mar 4, 2019 · 1 comment

Comments

@testica
Copy link

testica commented Mar 4, 2019

I want to show a PopupMenu when a node in long clicked.

treeView.setDefaultNodeLongClickListener { node, value ->
    // show popup to remove file
    val popup = PopupMenu(context!!, node.viewHolder.view)
    //Inflating the Popup using xml file
    popup.menuInflater
        .inflate(R.menu.file_menu, popup.menu)
    popup.show()
    true
}

In PopupMenu(context!!, node.viewHolder.view) I need to set a view to hook the popup menu, but node.viewHolder.view don't show nothing as result.

What is the proper view of node ?

@testica
Copy link
Author

testica commented Mar 6, 2019

I got a solution:

Inside createNodeView in BaseNodeViewHolder

view.id = node!!.id

So, in setDefaultNodeLongClickListener I got view reference through id:

treeView.setDefaultNodeLongClickListener { node, value ->
    // show popup to remove file
    val popup = PopupMenu(context!!, vFiles.findViewById(node.id))
    //Inflating the Popup using xml file
    popup.menuInflater
        .inflate(R.menu.file_menu, popup.menu)
    popup.show()
    true
}

vFiles is the container view of treeview

@testica testica closed this as completed Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant