Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

App starts then closes

$
0
0

Hi all,

I am new to Xamarin andd not new to c#.. but I am running into issue here. My app in the android emulator starts and quickly closes before all the contents are loaded.

Here is my code. Just a simple hello world

namespace Helloword
{
    [Activity (Label = "Helloworld", MainLauncher = true)]
    public class MainActivity : Activity
    {

        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
            LinearLayout ll = new LinearLayout (this);
            ll.Orientation = Orientation.Vertical;

            TextView label = new TextView (this);
            label.Text = "Hi There";

            Button btn = new Button (this);
            btn.Text = "click me";
            btn.Click += (object sender, EventArgs e) =>
            {
                label.Text = "good";
                btn.Text = "you clicked me";
            };

            ll.AddView(btn);
            ll.AddView(label);
            SetContentView(ll);

        }
    }
}

anything I'm doing wrong?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>