控件显示在设计器中,而不显示在模拟器中 [英] Controls showing in designer but not in emulator

查看:103
本文介绍了控件显示在设计器中,而不显示在模拟器中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个Xamarin应用程序.我在Visual Studio中设置了我的环境,并有一个可以在Android模拟器中运行的模板项目.

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.

我尝试过:

  • 清洁溶液
  • 重建解决方案
  • 手动删除bin和目标文件
  • 在项目Android选项中取消选中使用快速部署"
  • 从模拟器中卸载

但是每次都具有相同的结果.

But with the same result each time.

[已删除项目文件]

[Project files removed]

我想念什么吗?

推荐答案

只需下载您的代码并运行它即可.取消对SetContentView (Resource.Layout.Main);的评论对我有用.

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);
    }
}

此处一个很好的指南,助您一臂之力从Xamarin Android开始.

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

这篇关于控件显示在设计器中,而不显示在模拟器中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆