我尝试为xamarin开发的交叉平台应用程序获取磁场数据。我是一个移动开发的初学者,尤其是Xamarin。所以我有Hello Word代码:
public App ()
{
// The root page of your application
MainPage = new ContentPage {
Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
Children = {
new Label {
XAlign = TextAlignment.Center,
Text = "Welcome to Xamarin Forms!"
}
}
}
};
}我想在第一页显示磁力计的3个坐标值。
设备运动插件是一个多形式的插件,我也有这个代码,但我不知道如何在应用程序中显示这些值。
CrossDeviceMotion.Current.Start(MotionSensorType.Magnetometer);
CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
{
switch (a.SensorType)
{
case MotionSensorType.Magnetometer:
Debug.WriteLine("A: {0},{1},{2}", ((MotionVector)a.Value).X, ((MotionVector)a.Value).Y, ((MotionVector)a.Value).Z);
break;
}
};https://stackoverflow.com/questions/38240982
复制相似问题