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

Is it possible to make edges clickable? #79

Open
Ballistx opened this issue Mar 23, 2021 · 3 comments
Open

Is it possible to make edges clickable? #79

Ballistx opened this issue Mar 23, 2021 · 3 comments

Comments

@Ballistx
Copy link

Is it somehow possible to make the edges clickable? For example, I want to start a new activity when the edge between two specific nodes is clicked.

@DennisBlock
Copy link
Contributor

This is not possible. The edges are just drawn on the canvas. In the next version, we want to switch to a recyclerview version, where the edges are drawn with an ItemDecoration, but I don't think it will be possible there either. At least for now. Furthermore it could be hard to differentiate the edges if they are overlapping (depending on the chosen algorithm).

@shahram-noorani
Copy link

shahram-noorani commented Jun 13, 2021

hi. you can use thie code for clickable node :
adapter = object : AbstractGraphAdapter() {

    // 4.2 ViewHolder should extend from `RecyclerView.ViewHolder`
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NodeViewHolder {
        val view = LayoutInflater.from(parent.context)
                .inflate(R.layout.node, parent, false)
       
        return NodeViewHolder(view)
    }

    override fun onBindViewHolder(holder: NodeViewHolder, position: Int) {
        holder.textView.text = getNodeData(position).toString()
        //set tag for on click data - you can save position or node data 
        holder.textView.tag=getNodeData(position).toString()
        holder.textView.setOnclick{
            //click node // get tag data in view clicked
        }
    }
}.apply {
    // 4.3 Submit the graph
    this.submitGraph(graph)
    recycler.adapter = this
}
@GregorBlock
Copy link
Contributor

@shahram-noorani, the question was whether and how to react to clicks on the edges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants