public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.fragment_default, null, false); ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container); statusBar = rootView.FindViewById <TextView>(Resource.Id.status_bar); TreeNode root = TreeNode.InvokeRoot(); TreeNode computerRoot = new TreeNode(new IconTreeItem(Resource.String.ic_laptop, "My Computer")); TreeNode myDocuments = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "My Documents")); TreeNode downloads = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Downloads")); TreeNode file1 = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 1")); TreeNode file2 = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 2")); TreeNode file3 = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 3")); TreeNode file4 = new TreeNode(new IconTreeItem(Resource.String.ic_drive_file, "Folder 4")); fillDownloadsFolder(downloads); downloads.AddChildren(file1, file2, file3, file4); TreeNode myMedia = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Photos")); TreeNode photo1 = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 1")); TreeNode photo2 = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 2")); TreeNode photo3 = new TreeNode(new IconTreeItem(Resource.String.ic_photo_library, "Folder 3")); myMedia.AddChildren(photo1, photo2, photo3); myDocuments.AddChild(downloads); computerRoot.AddChildren(myDocuments, myMedia); root.AddChildren(computerRoot); tView = new AndroidTreeView(Activity, root); tView.SetDefaultAnimation(true); tView.SetDefaultContainerStyle(Resource.Style.TreeNodeStyleCustom); tView.SetDefaultViewHolder(Java.Lang.Class.FromType(typeof(IconTreeItemHolder))); tView.SetDefaultNodeClickListener(new CustomTreeNodeClickListener(statusBar)); tView.SetDefaultNodeLongClickListener(new CustomTreeNodeLongClickListener(Activity)); containerView.AddView(tView.View); if (savedInstanceState != null) { string state = savedInstanceState.GetString("tState"); if (!string.IsNullOrEmpty(state)) { tView.RestoreState(state); } } return(rootView); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.Inflate(Resource.Layout.fragment_selectable_nodes, null, false); rootView.FindViewById(Resource.Id.status).Visibility = ViewStates.Gone; ViewGroup containerView = rootView.FindViewById <ViewGroup>(Resource.Id.container); TreeNode root = TreeNode.InvokeRoot(); TreeNode s1 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Folder with very long name ")).SetViewHolder(new ArrowExpandSelectableHeaderHolder(Activity)); TreeNode s2 = new TreeNode(new IconTreeItem(Resource.String.ic_folder, "Another folder with very long name")).SetViewHolder(new ArrowExpandSelectableHeaderHolder(Activity)); fillFolder(s1); fillFolder(s2); root.AddChildren(s1, s2); tView = new AndroidTreeView(Activity, root); tView.SetDefaultAnimation(true); tView.SetUse2dScroll(true); tView.SetDefaultContainerStyle(Resource.Style.TreeNodeStyleCustom); tView.SetDefaultViewHolder(Java.Lang.Class.FromType(typeof(ArrowExpandSelectableHeaderHolder))); tView.SetDefaultNodeClickListener(new CustomTreeNodeClickListener(Activity)); containerView.AddView(tView.View); tView.ExpandAll(); if (savedInstanceState != null) { string state = savedInstanceState.GetString("tState"); if (!string.IsNullOrEmpty(state)) { tView.RestoreState(state); } } return(rootView); }