Xamarin android c#在3秒钟后调用或显示活动
我想在3秒钟后调用一个活动。我试过用线,但不起作用Xamarin android c#在3秒钟后调用或显示活动,c#,xamarin,xamarin.android,C#,Xamarin,Xamarin.android,我想在3秒钟后调用一个活动。我试过用线,但不起作用 [Activity(Label = "App1", MainLauncher = true, Icon = "@drawable/icon")] public class MainActivity : Activity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our v
[Activity(Label = "App1", 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.Login);
Button myButton = FindViewById<Button>(Resource.Id.button4);
myButton.Click += delegate
{
StartActivity(typeof(Register));
};
new Handler().postDelayed(new Runnable()
{
public void run()
{
//After 3 second will call this activity
StartActivity(typeof(MainActivity));
}
}, 5000);
}
}
[活动(Label=“App1”,MainLauncher=true,Icon=“@drawable/Icon”)]
公共课活动:活动
{
创建时受保护的覆盖无效(捆绑包)
{
base.OnCreate(bundle);
//从“主”布局资源设置视图
SetContentView(Resource.Layout.Login);
Button myButton=FindViewById(Resource.Id.button4);
myButton.单击+=委派
{
StartActivity(类型(寄存器));
};
new Handler().postDelayed(new Runnable())
{
公开募捐
{
//3秒后将调用此活动
启动性(类型(主要活动));
}
}, 5000);
}
}
lambda语法
myButton.Click += async (sender, args) =>
{
await Task.Delay(3000);
StartActivity(typeof (Register));
};
lambda语法
myButton.Click += async (sender, args) =>
{
await Task.Delay(3000);
StartActivity(typeof (Register));
};
你也可以使用
Java.Lang.Runnable runnable = new Java.Lang.Runnable(() =>
{
Intent i = new Intent(this, typeof(MainActivity));
StartActivity(i);
});
new Handler().PostDelayed(runnable, 1000);
你也可以使用
Java.Lang.Runnable runnable = new Java.Lang.Runnable(() =>
{
Intent i = new Intent(this, typeof(MainActivity));
StartActivity(i);
});
new Handler().PostDelayed(runnable, 1000);
是否要在延迟3秒后开始注册活动?是否要在延迟3秒后开始注册活动?