Skip to content

Instantly share code, notes, and snippets.

@Abdelsattar
Created October 9, 2016 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Abdelsattar/64122a63ae3bc87f23856fc0e826c449 to your computer and use it in GitHub Desktop.
Save Abdelsattar/64122a63ae3bc87f23856fc0e826c449 to your computer and use it in GitHub Desktop.
public class CheckBoxHolder extends TreeNode.BaseNodeViewHolder<CheckBoxHolder.IconTreeItem> {
boolean isChild;
public CheckBoxHolder(Context context, boolean isChild) {
super(context);
this.isChild = isChild;
}
@Override
public View getView() {
return super.getView();
}
@Override
public View createNodeView(final TreeNode node, IconTreeItem value) {
final LayoutInflater inflater = LayoutInflater.from(context);
final View view = inflater.inflate(R.layout.tree_node_checkbox, null, false);
TextView tvValue = (TextView) view.findViewById(R.id.text);
final CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
tvValue.setText(value.text);
checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked){
// give me error on getTreeView
//node.getTreeView().expand(node) ;
}
}
});
RelativeLayout relativeLayout = (RelativeLayout) view.findViewById(R.id.rel_layout);
if (!isChild)
relativeLayout.setBackgroundColor(context.getResources().getColor(R.color.grey));
return view;
}
public static class IconTreeItem {
public int icon;
public String text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment