Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.locationLayout);

            deleteBtn = FindViewById <Button>(Resource.Id.deleteBtn);

            backBtn = FindViewById <ImageButton>(Resource.Id.backBtn);

            counDisplayertBtn = FindViewById <Button>(Resource.Id.counDisplayertBtn);

            linLyt = FindViewById <LinearLayout>(Resource.Id.linLyt);

            listLocation = FindViewById <ListView>(Resource.Id.listLocation);



            listLocation.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, LocationsRepository.DisplayTableContent());

            msg = Resources.GetText(Resource.String.clickInfo);
            if (savedInstanceState != null)
            {
                counter = savedInstanceState.GetInt("counter", 0);
            }
            else
            {
                counter = 0;
            }
            counDisplayertBtn.Text = $"{counter++} { msg}";
            clickInfo      = new Button(this);
            backBtn.Click += delegate
            {
                Intent intent = new Intent(this, typeof(LocationActivity));

                StartActivity(intent);
            };
            counDisplayertBtn.Click += delegate
            {
                counDisplayertBtn.Text = $"{counter++} { msg}";
            };

            deleteBtn.Click += (s, e) =>
            {
                LocationsRepository.DeleteContent();
                listLocation.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, Array.Empty <string>());
            };
        }