Example #1
0
        private void List_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            var listView = sender as ListView;

            if (listView == null)
            {
                return;
            }
            NodeListAdapter listAdapter = listView.Adapter as NodeListAdapter;

            if (listAdapter != null)
            {
                var      node        = listAdapter.GetItem(e.Position);
                BaseNode currentNode = monitorAct.currentNode;
                if (node == null && currentNode != null && currentNode.ParentNode != null)
                {
                    currentNode = currentNode.ParentNode;
                }
                if (node != null)
                {
                    currentNode = node;
                }
                monitorAct.currentNode = currentNode;
                if (currentNode.Children.Count == 0)
                {
                    ShowDetailFragment();
                }
                else
                {
                    UpdateListView(currentNode);
                }
            }
        }
Example #2
0
        void UpdateListView(BaseNode node)
        {
            if (node == null)
            {
                return;
            }

            TextView txtPath = monitorAct.FindViewById <TextView>(Resource.Id.textViewFullPath);

            txtPath.Text = node.GetFullPath();

            ListView listView = monitorAct.FindViewById <ListView>(Resource.Id.listView1);

            if (listView.Adapter == null)
            {
                var items = new List <BaseNode>();
                listView.Adapter = new NodeListAdapter(monitorAct, items);
            }
            NodeListAdapter listAdapter = listView.Adapter as NodeListAdapter;

            if (listAdapter != null && node != null)
            {
                listAdapter.Clear();
                if (node.ParentNode != null)
                {
                    listAdapter.Add(null);
                }
                foreach (BaseNode child in node.Children)
                {
                    listAdapter.Add(child);
                }
            }
        }