Home > Uncategorized > Hello World, Xamarin C# for Android

Hello World, Xamarin C# for Android


Pretty cool stuff to see C# code run natively on Android, using Xamarin and Mono. Not sure if I’ll be moving from Phonegap yet, but, it’s got great potential.

Here’s the Main Activity in C#:

using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace XamarinHelloWorld
[Activity (Label = “Xamarin-HelloWorld”, MainLauncher = true, Icon = “@drawable/icon”)]
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 button = FindViewById<Button> (Resource.Id.myButton);

button.Click += delegate {
button.Text = string.Format (“{0} clicks!”, count++);


And, I had to tweak the AndroidManifest.xml:

<?xml version=”1.0″ encoding=”utf-8″?>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android” android:versionCode=”1″ android:versionName=”1.0″ package=”Xamarin_HelloWorld.Xamarin_HelloWorld”&gt;
<uses-sdk android:targetSdkVersion=”19″ android:minSdkVersion=”19″ />
<application android:label=”Xamarin-HelloWorld”></application>

This was because I was using an API level 19 Emulator, and got this “minimum android version not supported by device” xamarin error whenever I tried to kick it off.


Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: