【发布时间】:2011-10-17 22:31:04
【问题描述】:
我卸载了 android ask 并重新安装到 c:\androidSdktools 没有空格。 所以现在模拟器工作了,我可以看到模拟器了。
但是尝试了“hello world”文本的一些代码,当我运行应用程序并运行模拟器时,我看到了 android 模拟器,但我看不到 wnyhere“hello world”。 我不确定我是否没有做任何好事,或者可能是因为退出模拟器并停止调试时我仍然收到错误消息说:部署错误。如果我说“是”继续,那么他要求我在运行/调试它之前重建/构建我的解决方案,但它没有解决这个错误。
我不知道这个错误是否与我在 android 模拟器中没有看到任何“hello world”文本这一事实有关。
我现在尝试编写此代码:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace MonoAndroidApplication1
{
[Activity(Label = "MonoAndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : 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 button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
}
}
我有visual studio c# 2010 pro。
我试过了,这是我选择制作新的 android mono 应用程序时创建的自动代码。
但我在模拟器中没有看到任何文字。我尝试将此代码添加为:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace MonoAndroidApplication1
{
[Activity(Label = "MonoAndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")]
public class Activity1 : Activity
{
int count = 1;
TextView tv;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
tv = new TextView(this);
tv.Text = "hello world";
SetContentView(tv);
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
}
}
在运行模拟器时,我在模拟器中没有看到任何文本“hello world” 退出模拟器并停止调试/运行应用程序时仍然会出现此部署错误。模拟器现在运行良好,但退出时仍然出现此错误。
为什么我在模拟器上看不到文字“hello world”?
谢谢。
【问题讨论】:
-
“Cuz”不是一个词,请花时间写出完整的“因为”这个词。几乎没有足够非正式的上下文来证明使用“cuz”是合理的。
标签: c# android mono xamarin.android