public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView =  inflater.Inflate(Resource.Layout.fragment_list_view_wrap, container, false);

            this.listView = (RadListView)rootView.FindViewById(Resource.Id.listView).JavaCast<RadListView>();

            wrapLayoutManager = new WrapLayoutManager(Activity);
            this.listView.SetLayoutManager(wrapLayoutManager);

            MyWrapLayoutAdapter myWrapAdapter = new MyWrapLayoutAdapter(GetData());
            this.listView.SetAdapter(myWrapAdapter);

            Button orientationBtn = (Button)rootView.FindViewById (Resource.Id.orientationBtn);
            orientationBtn.Click += (object sender, EventArgs e) => {
                if(wrapLayoutManager.CanScrollHorizontally()) {
                    wrapLayoutManager = new WrapLayoutManager(Activity, OrientationHelper.Vertical);
                } else {
                    wrapLayoutManager = new WrapLayoutManager(Activity, OrientationHelper.Horizontal);
                }
                listView.SetLayoutManager(wrapLayoutManager);
            };

            Button lineSpacingBtn = (Button)rootView.FindViewById (Resource.Id.lineSpacingBtn);
            lineSpacingBtn.Click += (object sender, EventArgs e) => {
                if(wrapLayoutManager.LineSpacing == 0) {
                    wrapLayoutManager.LineSpacing = 20;
                } else {
                    wrapLayoutManager.LineSpacing = 0;
                }
            };

            Button minItemSpacingBtn = (Button)rootView.FindViewById (Resource.Id.minItemSpacingBtn);
            minItemSpacingBtn.Click += (object sender, EventArgs e) => {
                if(wrapLayoutManager.MinimumItemSpacing == 0) {
                    wrapLayoutManager.MinimumItemSpacing = 20;
                } else {
                    wrapLayoutManager.MinimumItemSpacing = 0;
                }
            };

            Button gravityBtn = (Button)rootView.FindViewById (Resource.Id.gravityBtn);
            gravityBtn.Click += (object sender, EventArgs e) => {
                gravityCounter++;
                if(gravityCounter > 6) {
                    gravityCounter = 1;
                }
                switch (gravityCounter) {
                case 1: wrapLayoutManager.Gravity = (int)(GravityFlags.End | GravityFlags.Bottom); break;
                case 2: wrapLayoutManager.Gravity = (int)(GravityFlags.End | GravityFlags.Top); break;
                case 3: wrapLayoutManager.Gravity = (int)(GravityFlags.Start | GravityFlags.Bottom); break;
                case 4: wrapLayoutManager.Gravity = (int)(GravityFlags.Start | GravityFlags.Top); break;
                case 5: wrapLayoutManager.Gravity = (int)(GravityFlags.CenterHorizontal | GravityFlags.CenterVertical); break;
                case 6: wrapLayoutManager.Gravity = (int)(GravityFlags.FillHorizontal | GravityFlags.FillVertical); break;
                }
            };

            return rootView;
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_list_view_layouts, container, false);
            this.listView = (RadListView)rootView.FindViewById(Resource.Id.listView).JavaCast<RadListView>();

            ArrayList source = new ArrayList();
            for (int i = 0; i < 50; i++) {
                source.Add(this.getRandomText());
            }
            this.listView.SetAdapter(new LayoutsListViewAdapter(source));

            Button btnLinear = (Button)rootView.FindViewById(Resource.Id.btnLinear);
            btnLinear.Click += (object sender, EventArgs e) => {
                listView.SetLayoutManager(new LinearLayoutManager(this.Activity));
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnStaggered = (Button)rootView.FindViewById(Resource.Id.btnStaggered);
            btnStaggered.Click += (object sender, EventArgs e) => {
                StaggeredGridLayoutManager slm = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical);
                listView.SetLayoutManager(slm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnGrid = (Button)rootView.FindViewById(Resource.Id.btnGrid);
            btnGrid.Click += (object sender, EventArgs e) => {
                GridLayoutManager glm = new GridLayoutManager(this.Activity, 3, GridLayoutManager.Vertical, false);
                listView.SetLayoutManager(glm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnDeck = (Button)rootView.FindViewById(Resource.Id.btnDeck);
            btnDeck.Click += (object sender, EventArgs e) => {
                DeckOfCardsLayoutManager dclm = new DeckOfCardsLayoutManager(this.Activity);
                listView.SetLayoutManager(dclm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnSlide = (Button)rootView.FindViewById(Resource.Id.btnSlide);
            btnSlide.Click += (object sender, EventArgs e) => {
                SlideLayoutManager slm = new SlideLayoutManager(this.Activity);
                listView.SetLayoutManager(slm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnWrap = (Button)rootView.FindViewById(Resource.Id.btnWrap);
            btnWrap.Click += (object sender, EventArgs e) => {
                WrapLayoutManager wlm = new WrapLayoutManager(this.Activity);
                listView.SetLayoutManager(wlm);
                listView.SetAdapter(new MyWrapAdapter(source));
            };

            return rootView;
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_list_view_wrap, container, false);

            this.listView = (RadListView)rootView.FindViewById(Resource.Id.listView).JavaCast <RadListView>();

            wrapLayoutManager = new WrapLayoutManager(Activity);
            this.listView.SetLayoutManager(wrapLayoutManager);

            MyWrapLayoutAdapter myWrapAdapter = new MyWrapLayoutAdapter(GetData());

            this.listView.SetAdapter(myWrapAdapter);

            Button orientationBtn = (Button)rootView.FindViewById(Resource.Id.orientationBtn);

            orientationBtn.Click += (object sender, EventArgs e) => {
                if (wrapLayoutManager.CanScrollHorizontally())
                {
                    wrapLayoutManager = new WrapLayoutManager(Activity, OrientationHelper.Vertical);
                }
                else
                {
                    wrapLayoutManager = new WrapLayoutManager(Activity, OrientationHelper.Horizontal);
                }
                listView.SetLayoutManager(wrapLayoutManager);
            };

            Button lineSpacingBtn = (Button)rootView.FindViewById(Resource.Id.lineSpacingBtn);

            lineSpacingBtn.Click += (object sender, EventArgs e) => {
                if (wrapLayoutManager.LineSpacing == 0)
                {
                    wrapLayoutManager.LineSpacing = 20;
                }
                else
                {
                    wrapLayoutManager.LineSpacing = 0;
                }
            };

            Button minItemSpacingBtn = (Button)rootView.FindViewById(Resource.Id.minItemSpacingBtn);

            minItemSpacingBtn.Click += (object sender, EventArgs e) => {
                if (wrapLayoutManager.MinimumItemSpacing == 0)
                {
                    wrapLayoutManager.MinimumItemSpacing = 20;
                }
                else
                {
                    wrapLayoutManager.MinimumItemSpacing = 0;
                }
            };

            Button gravityBtn = (Button)rootView.FindViewById(Resource.Id.gravityBtn);

            gravityBtn.Click += (object sender, EventArgs e) => {
                gravityCounter++;
                if (gravityCounter > 6)
                {
                    gravityCounter = 1;
                }
                switch (gravityCounter)
                {
                case 1: wrapLayoutManager.Gravity = (int)(GravityFlags.End | GravityFlags.Bottom); break;

                case 2: wrapLayoutManager.Gravity = (int)(GravityFlags.End | GravityFlags.Top); break;

                case 3: wrapLayoutManager.Gravity = (int)(GravityFlags.Start | GravityFlags.Bottom); break;

                case 4: wrapLayoutManager.Gravity = (int)(GravityFlags.Start | GravityFlags.Top); break;

                case 5: wrapLayoutManager.Gravity = (int)(GravityFlags.CenterHorizontal | GravityFlags.CenterVertical); break;

                case 6: wrapLayoutManager.Gravity = (int)(GravityFlags.FillHorizontal | GravityFlags.FillVertical); break;
                }
            };

            return(rootView);
        }
Exemplo n.º 4
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            View rootView = inflater.Inflate(Resource.Layout.fragment_list_view_layouts, container, false);

            this.listView = (RadListView)rootView.FindViewById(Resource.Id.listView).JavaCast <RadListView>();

            ArrayList source = new ArrayList();

            for (int i = 0; i < 50; i++)
            {
                source.Add(this.getRandomText());
            }
            this.listView.SetAdapter(new LayoutsListViewAdapter(source));

            Button btnLinear = (Button)rootView.FindViewById(Resource.Id.btnLinear);

            btnLinear.Click += (object sender, EventArgs e) => {
                listView.SetLayoutManager(new LinearLayoutManager(this.Activity));
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnStaggered = (Button)rootView.FindViewById(Resource.Id.btnStaggered);

            btnStaggered.Click += (object sender, EventArgs e) => {
                StaggeredGridLayoutManager slm = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.Vertical);
                listView.SetLayoutManager(slm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnGrid = (Button)rootView.FindViewById(Resource.Id.btnGrid);

            btnGrid.Click += (object sender, EventArgs e) => {
                GridLayoutManager glm = new GridLayoutManager(this.Activity, 3, GridLayoutManager.Vertical, false);
                listView.SetLayoutManager(glm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnDeck = (Button)rootView.FindViewById(Resource.Id.btnDeck);

            btnDeck.Click += (object sender, EventArgs e) => {
                DeckOfCardsLayoutManager dclm = new DeckOfCardsLayoutManager(this.Activity);
                listView.SetLayoutManager(dclm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnSlide = (Button)rootView.FindViewById(Resource.Id.btnSlide);

            btnSlide.Click += (object sender, EventArgs e) => {
                SlideLayoutManager slm = new SlideLayoutManager(this.Activity);
                listView.SetLayoutManager(slm);
                listView.SetAdapter(new LayoutsListViewAdapter(source));
            };

            Button btnWrap = (Button)rootView.FindViewById(Resource.Id.btnWrap);

            btnWrap.Click += (object sender, EventArgs e) => {
                WrapLayoutManager wlm = new WrapLayoutManager(this.Activity);
                listView.SetLayoutManager(wlm);
                listView.SetAdapter(new MyWrapAdapter(source));
            };

            return(rootView);
        }