Mike
Mike

Reputation: 2396

Layout not appearing - rather a blank screen

I am new to Android development and have encountered a problem with displaying a Layout I have created - I have a main activity and a layout that loads at startup - and I would like a another Layout to be shown when a button is pressed - but instead of showing the other layout a blank screen is shown (there is a textfield on the other layout so it should not be blank) - have I missed something here?

public class MainActivity : Activity
{
    int count = 1;

    protected override void OnCreate (Bundle bundle)

    {
        base.OnCreate (bundle);

        // 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 num1 = FindViewById<Button> (Resource.Id.num1Button);

        num1.Click += delegate {

            //button.Text = string.Format ("This is runtime text");
            SetContentView (Resource.Layout.Num1Layout);
        };
    }
}

Upvotes: 1

Views: 71

Answers (1)

Related Questions