@Override public LinearLayout updateView(final View view, final TreeNodeInfo<Long> treeNodeInfo) { int level = treeNodeInfo.getLevel(); final LinearLayout viewLayout = (LinearLayout) view; if (level == 0) { // Header final TextView txtHeaderTitle = (TextView) viewLayout.findViewById(R.id.headerTitle); final TextView txtHeaderCount = (TextView) viewLayout.findViewById(R.id.headerCount); long id = treeNodeInfo.getId(); txtHeaderTitle.setText(TreeViewListDemo.Header[(int) id]); txtHeaderCount.setText(String.valueOf(id)); } else if (level == 1) { // Group final TextView txtGroupTitle = (TextView) viewLayout.findViewById(R.id.groupTitle); final TextView txtGroupCount = (TextView) viewLayout.findViewById(R.id.groupCount); long id = treeNodeInfo.getId(); txtGroupTitle.setText("Level " + id); txtGroupCount.setText(String.valueOf(id)); } else { // Child final TextView txtChildTitle = (TextView) viewLayout.findViewById(R.id.childTitle); final TextView txtChildCategoryText = (TextView) viewLayout.findViewById(R.id.childCategoryText); long id = treeNodeInfo.getId(); txtChildTitle.setText("Sub Level " + id); txtChildCategoryText.setText("Sub Level Text " + String.valueOf(id) + " Goes Here"); } return viewLayout; }
@Override public View getNewChildView(final TreeNodeInfo<Long> treeNodeInfo) { int level = treeNodeInfo.getLevel(); LinearLayout viewLayout; if (level == 0) { viewLayout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.header, null); return updateView(viewLayout, treeNodeInfo); } else if (level == 1) { viewLayout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.groups, null); return updateView(viewLayout, treeNodeInfo); } else if (level == 2) { viewLayout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.childs, null); return updateView(viewLayout, treeNodeInfo); } else { viewLayout = (LinearLayout) getActivity().getLayoutInflater().inflate(R.layout.childs, null); return updateView(viewLayout, treeNodeInfo); } }