gbro3n
gbro3n

Reputation: 6967

Controls showing in designer but not in emulator

This is my first Xamarin app. I have my environment set up in Visual Studio, and have a template project which I can run in the Android emulator.

Having dragged and dropped a couple of controls on to the designer surface, I find that when I run the application in the emulator, neither of the two controls that I have added (a button and a switch) display in the emulator.

I have tried:

But with the same result each time.

enter image description here

[Project files removed]

Am I missing something?

Upvotes: 1

Views: 2271

Answers (3)

NATHANIAL COVELL
NATHANIAL COVELL

Reputation: 1

In my case, I had to update my Main.xml file with the updates I put into the Main.axml and Rebuild.

Upvotes: 0

Amit K Khanchandani
Amit K Khanchandani

Reputation: 355

navigate to MainActivity.cs and uncomment this code

SetContentView (Resource.Layout.Main);

and rebuild the solution and debug.

Let me know it if helps!

Upvotes: 2

pinedax
pinedax

Reputation: 9346

Just downloaded your code and ran it. Uncommenting SetContentView (Resource.Layout.Main); it worked to me.

[Activity(Label = "Tgo.AndroidApp", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView (Resource.Layout.Main);
    }
}

Here a nice guide to get you started with Xamarin Android.

Upvotes: 6

Related Questions