private void bindData() { // reference TreeViewList treeView = (TreeViewList) mRootView.findViewById(android.R.id.list); ViewGroup emptyView = (ViewGroup) mRootView.findViewById(android.R.id.empty); // treeview content if (mAdapter == null) { // create adapter mAdapter = new TreeListingAdapter( getActivity(), mProductList, mSelectedSet, mTreeStateManager, TREEVIEW_DEPTH); } else { // refresh adapter mAdapter.refresh(); mAdapter.notifyDataSetChanged(); } // set adapter treeView.setAdapter(mAdapter); // treeview parameters treeView.setCollapsible(true); treeView.setEmptyView(emptyView); treeView.setOnItemClickListener(this); // context menu registerForContextMenu(treeView); }
private int getListPosition(int globalPosition) { // reference TreeViewList treeView = (TreeViewList) mRootView.findViewById(android.R.id.list); // list position without headers, should be used for getting data entities from collections int listPosition = globalPosition; if (treeView != null) listPosition = globalPosition - treeView.getHeaderViewsCount(); return listPosition; }