GraphView icon indicating copy to clipboard operation
GraphView copied to clipboard

Is it possible to make edges clickable?

Open Ballistx opened this issue 4 years ago • 3 comments

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.

Ballistx avatar Mar 23 '21 22:03 Ballistx

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).

DennisBlock avatar Mar 25 '21 13:03 DennisBlock

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

    // 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
}

shahram-noorani avatar Jun 13 '21 14:06 shahram-noorani

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

GregorBlock avatar Jun 15 '21 11:06 GregorBlock