我想在用户登录xamarin.android
应用后在textview中显示天文钟。该怎么做?
这是我的代码的一部分:
这是我的代码的一部分:
xaml
<TextView
android:text="Dzisiaj pracujesz już:\n"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_alignParentTop="true"
android:layout_marginTop="226dp"
android:textStyle="bold"
android:textSize="24sp"
android:textColor="#ffffff"
android:id="@+id/timeTextView"
android:layout_centerHorizontal="true"
android:theme="@style/MyCustomTheme"/>
LoginViewModel类
if (lg)
{
_appVariables.UserName = UserName;
_appVariables.logDate = DateTime.Now;
_appVariables.isLogged = true;
await GoToDashboard.Handle(Unit.Default);
logging = _appVariables.logDate.ToString();
}
答案 0 :(得分:0)
我不知道您需要实现什么,但这是在textview中显示计时器的示例:
private TextView tvTime;
private TimerCallback timerDelegate;
private int second;
private Timer _dispatcherTimer;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity);
FindViewById<Button>(Resource.Id.take).Click += CameraActivity_Click;
tvTime = FindViewById<TextView>(Resource.Id.time);
timerDelegate = new TimerCallback(Tick);
}
private void Tick(object state)
{
this.RunOnUiThread(() =>
{
tvTime.Text = (second++).ToString();
});
}
单击按钮后,文本视图将开始每秒计数。