Easy question for C# novice
using Android.App;
using Android.Widget;
using Android.OS;
namespace Sukkis
{
[Activity(Label = "sukkis", MainLauncher = true, Icon = "@mipmap/icon")]
public class MainActivity : Activity
{
string person = "sukkis";
string age = "24";
string place = "hell";
int count = 1;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.myButton);
TextView kentta = FindViewById<TextView>(Resource.Id.tiedot);
if (count == 2)
{
button.Click += delegate { kentta.Text = "Info"; };
button.Click += delegate { button.Text = "Click additional info"; };
count--;
}
else
{
button.Click += delegate { kentta.Text = $"Name: {person}\nage: {age}\nPlace: {place} \n \nC# is fun"; };
button.Click += delegate { button.Text = "Hide"; };
count++;
}
}
}
}
How to fix this function? Now that works when I press button first time but it wont run function again after second press. How to implement that if loop properly to change text after every other pressing button? Thanks for your answer.
Aucun commentaire:
Enregistrer un commentaire