Rana.M Rana.M - 11 months ago 75
Android Question

How to change the text of button?

How to change the text of button on the first click? Now it takes two clicks to change the text:

int countt1 = 3;
var buttonn1 = FindViewById<Button>(Resource.Id.buttonn1);

buttonn1.Click += (sender, e)=>
if (countt1 >= 0)
buttonn1.Text = string.Format("{0}", countt2--);


As @Jason points out, using the postfix decrement operator (countt2--) gives the value before the decrement occurs. For the value after the decrement occurs, change to the prefix decrement operator like this:

    buttonn1.Text = string.Format("{0}", --countt2);

C# reference.