Is it possible to make edges clickable?
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.
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).
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, the question was whether and how to react to clicks on the edges.