Exemple #1
0
        public bool OnChildClick(ExpandableListView parent, View v,
                                 int groupPosition, int childPosition, long id)
        {
            //Make a second selection, it adds that into the listitem...

            headers = new List <string>(CoffeeData.Keys);



            List <string> defaultHeaders = new List <string> ();

            defaultHeaders.Add("Coffee");
            defaultHeaders.Add("Size");
            defaultHeaders.Add("Milk");

            string currentKey = headers [groupPosition];

            List <string> values = CoffeeData [currentKey];

            string fixedKey;
            int    cutOff       = currentKey.IndexOf(":");
            string newGroupText = "";

            if (cutOff > 0)
            {
                fixedKey     = currentKey.Substring(0, cutOff);
                newGroupText = string.Empty;
                newGroupText = string.Concat(fixedKey, ": ",
                                             v.FindViewById <TextView> (Resource.Id.txtItemContent).Text);
            }
            else
            {
                original = string.Empty;

                if (groupPosition == 0)
                {
                    original = "Coffee";
                }
                else if (groupPosition == 1)
                {
                    original = "Milk";
                }
                else if (groupPosition == 2)
                {
                    original = "Size";
                }

                newGroupText = string.Concat(original, ": ",
                                             v.FindViewById <TextView> (Resource.Id.txtItemContent).Text);
            }

            headers [groupPosition] = newGroupText;

            CoffeeData.Remove(currentKey);
            CoffeeData.Add(headers [groupPosition], values);

            coffeeLv.CollapseGroup(groupPosition);
            coffeeAdapter.UpdateData(CoffeeData);

            if (groupPosition == 0)
            {
                TempStorage.Coffee = v.FindViewById <TextView> (Resource.Id.txtItemContent).Text;
            }
            else if (groupPosition == 1)
            {
                TempStorage.Milk = v.FindViewById <TextView> (Resource.Id.txtItemContent).Text;
            }
            else if (groupPosition == 2)
            {
                TempStorage.Size = v.FindViewById <TextView> (Resource.Id.txtItemContent).Text;
            }

            if (headers [0] != "Coffee" && headers [1] != "Milk" && headers [2] != "Size")
            {
                favourite.SetVisible(true);
            }

            return(true);
        }