public MySimpleOnPageChangeListener(CustomViewAbove view) { this.view = view; }
/// <summary> /// Instantiates a new SlidingMenu. /// </summary> /// <param name="context"> the associated Context </param> /// <param name="attrs"> the attrs </param> /// <param name="defStyle"> the def style </param> public SlidingMenu(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { LayoutParams behindParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mViewBehind = new CustomViewBehind(context); AddView(mViewBehind, behindParams); LayoutParams aboveParams = new LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent); mViewAbove = new CustomViewAbove(context); AddView(mViewAbove, aboveParams); // register the CustomViewBehind with the CustomViewAbove mViewAbove.CustomViewBehind = mViewBehind; mViewBehind.CustomViewAbove = mViewAbove; mViewAbove.SetInternalPageChangeListener(new MyOnPageChangeListener(this)); // now style everything! TypedArray ta = context.ObtainStyledAttributes(attrs, Resource.Styleable.SlidingMenu); // set the above and behind views if defined in xml int mode = ta.GetInt(Resource.Styleable.SlidingMenu_mode, LEFT); Mode = mode; int viewAbove = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewAbove, -1); if (viewAbove != -1) { SetContent(viewAbove); } else { SetContent(new FrameLayout(context)); } int viewBehind = ta.GetResourceId(Resource.Styleable.SlidingMenu_viewBehind, -1); if (viewBehind != -1) { SetMenu(viewBehind); } else { SetMenu(new FrameLayout(context)); } int touchModeAbove = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeAbove, TOUCHMODE_MARGIN); TouchModeAbove = touchModeAbove; int touchModeBehind = ta.GetInt(Resource.Styleable.SlidingMenu_touchModeBehind, TOUCHMODE_MARGIN); TouchModeBehind = touchModeBehind; int offsetBehind = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindOffset, -1); int widthBehind = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_behindWidth, -1); if (offsetBehind != -1 && widthBehind != -1) { throw new IllegalStateException("Cannot set both behindOffset and behindWidth for a SlidingMenu"); } else if (offsetBehind != -1) { BehindOffset = offsetBehind; } else if (widthBehind != -1) { BehindWidth = widthBehind; } else { BehindOffset = 0; } float scrollOffsetBehind = ta.GetFloat(Resource.Styleable.SlidingMenu_behindScrollScale, 0.33f); BehindScrollScale = scrollOffsetBehind; int shadowRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_shadowDrawable, -1); if (shadowRes != -1) { ShadowDrawableResource = shadowRes; } int shadowWidth = (int)ta.GetDimension(Resource.Styleable.SlidingMenu_shadowWidth, 0); ShadowWidth = shadowWidth; bool fadeEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_fadeEnabled, true); FadeEnabled = fadeEnabled; float fadeDeg = ta.GetFloat(Resource.Styleable.SlidingMenu_fadeDegree, 0.33f); FadeDegree = fadeDeg; bool selectorEnabled = ta.GetBoolean(Resource.Styleable.SlidingMenu_selectorEnabled, false); SelectorEnabled = selectorEnabled; int selectorRes = ta.GetResourceId(Resource.Styleable.SlidingMenu_selectorDrawable, -1); if (selectorRes != -1) { SelectorDrawable = selectorRes; } ta.Recycle(); }