bmelnychuk / AndroidTreeView

AndroidTreeView. TreeView implementation for android
Apache License 2.0
2.99k stars 618 forks source link

Passing listner to myholder #142

Open KACIAISSA opened 6 years ago

KACIAISSA commented 6 years ago

Hello, I am using Android treeView to update some TextViews in my interface with the value of the node. for that, I created a constructor with a listener as an input parameter to be able to call its methods. unfortunately, after setting m holder as default view holder, the listener is set normally, but when I click on a node and try to call its method, I get null pointer exception, and the listener is null. I understood that the default constructor is called for each item and my listener is not passed that's why. Any solution to my issue. thank you.

Summary : Have in an interface 2 TextView and TreeView. I need to set text on my view by clicking on some items of the treeview. for that I make my activity implements some listener. I create a Holder that takes my listener as input param. I implement the onClickListener and call my listener methods that fill the textview.

Error : null pointer exception on listener.

//Adding holder to the view

//Get treeView data AndroidTreeView tView = new AndroidTreeView(getActivity(), CountriesTree.getInstance().getTreeNode()); tView.setDefaultViewHolder(new TreeViewAdapter(getActivity().getApplicationContext()).getClass(),this); treeView.addView(tView.getView());

Thank you very much