protected override void OnElementChanged(ElementChangedEventArgs <Stepper> e) { base.OnElementChanged(e); if (e.OldElement == null) { _downButton = new AButton(Context) { Text = "-", Gravity = GravityFlags.Center, Tag = this }; _downButton.SetHeight((int)Context.ToPixels(10.0)); _downButton.SetOnClickListener(StepperListener.Instance); _upButton = new AButton(Context) { Text = "+", Tag = this }; _upButton.SetOnClickListener(StepperListener.Instance); _upButton.SetHeight((int)Context.ToPixels(10.0)); var layout = CreateNativeControl(); layout.AddView(_downButton); layout.AddView(_upButton); SetNativeControl(layout); } UpdateButtonEnabled(); }
private void initialSettings() { pageTitle = FindViewById <TextView>(Resource.Id.textViewtitle); messagePart1 = FindViewById <TextView>(Resource.Id.tvMessagePart1); messagePart2 = FindViewById <TextView>(Resource.Id.tvMessagePart2); Button messageBtn = FindViewById <Button>(Resource.Id.BtnMessageOk); messageBtn.SetOnClickListener(this); }
AButton AddButton(string name) { var button = new AButton(Context) { Text = name }; button.SetOnClickListener(this); _layout.AddView(button); return(button); }
protected override void OnElementChanged(ElementChangedEventArgs <Stepper> e) { base.OnElementChanged(e); if (e.OldElement == null) { _downButton = new Android.Widget.Button(Context) { Text = "-", Gravity = GravityFlags.Center, Tag = this }; //Set the MinWidth of Button _downButton.SetMinWidth(50); _downButton.SetOnClickListener(StepperListener.Instance); _upButton = new Android.Widget.Button(Context) { Text = "+", Tag = this }; _upButton.SetOnClickListener(StepperListener.Instance); //Set the MinWidth of Button _upButton.SetMinWidth(50); if (e.NewElement != null) { //Set the Width and Height of the button according to the WidthRequest _downButton.LayoutParameters = new LayoutParams((int)e.NewElement.WidthRequest, LayoutParams.MatchParent); _upButton.LayoutParameters = new LayoutParams((int)e.NewElement.WidthRequest, LayoutParams.MatchParent); } var layout = CreateNativeControl(); layout.AddView(_downButton); layout.AddView(_upButton); SetNativeControl(layout); } UpdateButtonEnabled(); }
protected override void OnElementChanged(ElementChangedEventArgs <Page> e) { base.OnElementChanged(e); if (e.OldElement != null || Element == null) { return; } if (e.NewElement != null) { activity = this.Context as Activity; view = activity.LayoutInflater.Inflate(Resource.Layout.main_layout, this, false); activity.SetContentView(view); material_card = (MaterialCardView)view.FindViewById(Resource.Id.material_card); localButton = (Android.Widget.Button)view.FindViewById(Resource.Id.button); localButton?.SetOnClickListener(this); textview = (TextView)view.FindViewById(Resource.Id.textview); linearLayoutCard = (LinearLayout)view.FindViewById(Resource.Id.linearLayoutCard); } }