Created
May 31, 2011 11:08
-
-
Save conceptdev/1000314 to your computer and use it in GitHub Desktop.
MonoDroid 'hello world' examples (simple, layout-less sample app)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Android.App; | |
using Android.OS; | |
using Android.Widget; | |
namespace Demo | |
{ | |
[Activity(Label = "HelloWorld", MainLauncher = true)] | |
public class HelloWorldActivity : Activity | |
{ | |
int count = 0; | |
Button b; | |
//TextView tv; | |
protected override void OnCreate(Bundle bundle) | |
{ | |
base.OnCreate(bundle); | |
b = new Button(this); | |
b.SetText("Click me", TextView.BufferType.Normal); | |
b.Click += delegate { b.Text = string.Format("{0} clicks!", ++count); }; | |
SetContentView(b); // example #1 | |
#region Example 2 | |
//tv = new TextView(this); | |
//tv.SetText("Welcome to MonoDroid...", Android.Widget.TextView.BufferType.Normal); | |
//LinearLayout ll = new LinearLayout(this); | |
//ll.Orientation = Orientation.Vertical; | |
//ll.AddView(tv); | |
//ll.AddView(b); | |
//SetContentView(ll); // example #2 | |
#endregion | |
#region Example 3 | |
//RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams(200, 50); | |
//b.LayoutParameters = rlp; | |
//tv.LayoutParameters = rlp; | |
//RelativeLayout rl = new RelativeLayout(this); | |
//rl.AddView(tv); | |
//rl.AddView(b); | |
//SetContentView(rl); // example #3 | |
#endregion | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment