Created
December 29, 2012 06:46
-
-
Save flockonus/4405026 to your computer and use it in GitHub Desktop.
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 System; | |
using Android.App; | |
using Android.Content; | |
using Android.Runtime; | |
using Android.Views; | |
using Android.Widget; | |
using Android.OS; | |
using System.Threading; | |
namespace HelloAndroid | |
{ | |
[Activity (Label = "HelloAndroid", MainLauncher = true)] | |
public class Activity1 : Activity | |
{ | |
int count; | |
protected override void OnCreate (Bundle bundle) | |
{ | |
base.OnCreate (bundle); | |
SwitchLayoutA(); | |
//base.OnCreate (bundle); | |
} | |
protected void SwitchLayoutA () | |
{ | |
//Create the user interface in code | |
var layout = new LinearLayout (this); | |
layout.Orientation = Orientation.Vertical; | |
var aLabel = new TextView (this); | |
aLabel.SetText(Resource.String.helloLabelText); | |
var aButton = new Button (this); | |
aButton.SetText(Resource.String.helloButtonText); | |
aButton.Click += (sender, e) => { | |
aLabel.Text = "Hello from the button"; | |
SwitchLayoutB (); | |
}; | |
layout.AddView (aLabel); | |
layout.AddView (aButton); | |
SetContentView (layout); | |
} | |
protected void SwitchLayoutB () | |
{ | |
// Set our view from the "main" layout resource | |
SetContentView (Resource.Layout.Main); | |
count = 1; | |
Button button = FindViewById<Button> (Resource.Id.myButton); | |
button.Click += delegate { | |
if( count > 3 ){ | |
System.Threading.Tasks.Task.Factory.StartNew (() => { | |
Thread.Sleep(3000); | |