private FlexibleView GetHorizontalFlexibleView() { horizontalFlexibleView = new FlexibleView(); Assert.IsNotNull(horizontalFlexibleView, "should be not null"); Assert.IsInstanceOf <FlexibleView>(horizontalFlexibleView, "should be an instance of testing target class!"); horizontalFlexibleView.Name = "FlexibleView"; horizontalFlexibleView.WidthSpecification = 400; horizontalFlexibleView.HeightSpecification = 450; horizontalFlexibleView.Padding = new Extents(10, 10, 10, 10); horizontalFlexibleView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f); List <ListItemData> dataList = new List <ListItemData>(); for (int i = 0; i < 4; ++i) { dataList.Add(new ListItemData(i)); } adapter = new ListBridge(dataList); horizontalFlexibleView.SetAdapter(adapter); horizontalFlexibleView.OnRelayout(scrnSize, null); horizontalLayoutManager = new LinearLayoutManager(LinearLayoutManager.HORIZONTAL); horizontalFlexibleView.SetLayoutManager(horizontalLayoutManager); horizontalFlexibleView.OnRelayout(scrnSize, null); return(horizontalFlexibleView); }
public static FlexibleView CreateGridFlexibleView(Vector2 scrnSize, int orientation, int itemCount) { var flexibleView = new FlexibleView(); Assert.IsNotNull(flexibleView, "should be not null"); Assert.IsInstanceOf <FlexibleView>(flexibleView, "should be an instance of testing target class!"); Assert.IsNotNull(flexibleView.Padding, "should be not null"); flexibleView.OnRelayout(scrnSize, null); flexibleView.Name = "RecyclerView1"; flexibleView.WidthSpecification = 400; flexibleView.HeightSpecification = 450; flexibleView.Padding = new Extents(10, 10, 10, 10); flexibleView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f); flexibleView.FocusedItemIndex = -1; flexibleView.FocusedItemIndex = 0; List <ListItemData> dataList = new List <ListItemData>(); for (int i = 0; i < itemCount; ++i) { dataList.Add(new ListItemData(i)); } var adapter = new ListBridge(dataList); flexibleView.SetAdapter(null); flexibleView.SetAdapter(adapter); flexibleView.OnRelayout(scrnSize, null); var layoutManager = new GridLayoutManager(3, orientation); flexibleView.SetLayoutManager(null); flexibleView.SetLayoutManager(layoutManager); flexibleView.OnRelayout(scrnSize, null); flexibleView.Focusable = true; return(flexibleView); }
private FlexibleView GetVerticalFlexibleView() { if (null == verticalFlexibleView) { verticalFlexibleView = new FlexibleView(); Assert.IsNotNull(verticalFlexibleView, "should be not null"); Assert.IsInstanceOf <FlexibleView>(verticalFlexibleView, "should be an instance of testing target class!"); verticalFlexibleView = new FlexibleView(); verticalFlexibleView.OnRelayout(scrnSize, null); verticalFlexibleView.Name = "RecyclerView1"; verticalFlexibleView.WidthSpecification = 400; verticalFlexibleView.HeightSpecification = 450; verticalFlexibleView.Padding = new Extents(10, 10, 10, 10); verticalFlexibleView.BackgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.4f); List <ListItemData> dataList = new List <ListItemData>(); for (int i = 0; i < 8; ++i) { dataList.Add(new ListItemData(i)); } adapter = new ListBridge(dataList); verticalFlexibleView.SetAdapter(adapter); verticalFlexibleView.OnRelayout(scrnSize, null); verticalLayoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); verticalFlexibleView.SetLayoutManager(verticalLayoutManager); verticalFlexibleView.OnRelayout(scrnSize, null); verticalFlexibleView.Focusable = true; verticalFlexibleView.KeyEvent += RecyclerView_KeyEvent; verticalFlexibleView.FocusGained += FlexibleView_FocusGained; verticalFlexibleView.FocusLost += FlexibleView_FocusLost; } return(verticalFlexibleView); }